Monday 27 February 2017

Report images change based on company name

Using different images  according to selection of company

here i am using  two images 

you can see two images in the picture















right click on the image and select   the image  properties and  click on the visibility tab 

now click on the expression  box and enter the  expression 



eg:=IIF(First(Fields!ItemId.Value, "student")="1101",False, True)

 after adding expression in one image now  repeat the same step  for another image 
but the  condition differs ( you can see the condition in below pic)
















Report generated is based on  my condition  parameter  itemid= 1003

Sunday 26 February 2017

Reversing NumberSequence

public void revSequenceByOne(ItemGroupId _groupId)
{
NumberSequenceTable     numberSeqTableRev,numberSeqLastRec;
InventItemGroup         invItemGroup;
str                     autonumber;
   
          ttsBegin;
          invItemGroup = InventItemGroup::find(_groupId);
   
          if (invItemGroup && invItemGroup.NumberSequenceCode)
          {
              autonumber = invItemGroup.NumberSequenceCode;
              numberSeqTableRev      = NumberSequenceTable::findByNaturalKey(autonumber);
   
              select forUpdate firstOnly numberSeqLastRec
                  where numberSeqLastRec.RecId == numberSeqTableRev.RecId;
              if (numberSeqLastRec.RecId && numberSeqLastRec.NextRec != 1)
              {
                 numberSeqLastRec.NextRec -= 1;
                 numberSeqLastRec.update();
              }
          }
          ttsCommit;
}

Validate for Another user not to use

public void  validatewrite(Args _args)
{
     boolean ret;
    NumberSequenceTable numberSequenceTable;
     LedgerJournalName  ledger;
    ledgerjournalname  tchk;
    LedgerJournalNameId  ledgerJournalNameId;
    select tchk where tchk.CheckBox== NoYes::Yes;
        if(tchk && tchk.JournalName!= ledger.JournalName)
        {
             ledger.CheckBox= NoYes::No;
             select tchk where tchk.CheckBox== NoYes::Yes;
            ret = checkFailed("Already Journal Name: %1 is Checked",tchk.JournalName) );
            // ret = checkFailed(strFmt("selected user",tchk.JournalName));
           // throw error ("already selected by one user");

}}

AOT Query Filter by range through code

static void Query_getRanges(Args _args)
{
    Query                   query = new Query();
    QueryRun                queryRun;
    QueryBuildDataSource    qbd;
    CustTable               custTable;
    QueryBuildRange         range;
    int                     cnt, i;
    ;

    qbd = query.addDataSource(tablenum(CustTable));

    queryRun = new QueryRun(query);

    queryRun.prompt();   // To Prompt the dialog

    cnt = queryRun.query().dataSourceTable(tablenum(CustTable)).rangeCount();

    for (i=1 ; i<=cnt; i++)
    {
        range = queryRun.query().dataSourceTable(tablenum(CustTable)).range(i);
        info(strfmt("Range Field %1, Value %2",range.AOTname(),range.value()));
    }

    while (queryRun.next())
    {
        custTable = queryRun.get(tablenum(CustTable));
        info(strfmt("Customer %1, Name %2",custTable.AccountNum, custTable.Name()));
    }
}

How to restrict numbers in an String

static void RestrictNumbersInString(Args _args)

{
#define.alphabets('ABCDEFGHIJKLMNOPQRSTUVWXYZ')
str     Field1;//is your field
;
Field1 = "pravin022kumar";

if((strkeep(substr(Field1,1,strlen(Field1)),#alphabets)!= substr(Field1,1, strlen(Field1))))
{
    info(strfmt("%1","You cannot enter other than alphabets"));
    }
    else
    {
    info(strfmt("%1",Field1));
    }

}

Saturday 25 February 2017

Creating NumberSequence Table Level

To Creating NumberSequence Table  Level
   

1.  Create an edt : CarId .

     AOT >> Extended Data Types >> New  >> Properties >> Name  >> Car Id.

2. Write a code on lode module() on NumberSeqModuleProject

{
     datatype.parmDatatypeId(extendedTypeNum(Car Id));
     datatype.parmReferenceHelp(literalStr("@SYS334483"));
     datatype.parmWizardIsManual(NoYes::No);
     datatype.parmWizardIsChangeDownAllowed(NoYes::No);
     datatype.parmWizardIsChangeUpAllowed(NoYes::No);
     datatype.parmWizardHighest(999999);
     datatype.parmSortField(20);
     datatype.addParameterType(NumberSeqParameterType::DataArea, truefalse);
     this.create(datatype);
}

3.Write a method on Projparameters Table

     client server static NumberSequenceReference numRefcarId()
{
     return NumberSeqReference::findReference(extendedTypeNum(car Id));
}

4.Write a job and run that

static void Carid(Args _args)
{
    NumberSeqModuleProject  NumberSeqModuleProject = new NumberSeqModuleProject();
    ;
    NumberSeqModuleProject.load();
}


5. Then run the wizard

   Organization Administration >> CommonForms >> Numbersequences>>Numbersequences>> Generate >> run the wizard.

6.Now we have to check the number sequence  is correctly working  for that write a job:

static void number(Args _args)
{
    NumberSeq  numberSeq;
    CarId num;
    ;
    numberSeq = NumberSeq::newGetNum(ProjParameters::numRefcarId());
    num = numberSeq.num();
    info(num);
}

  Run the above job.We will find the generated Numbersequence. 


Now Create a new method in  the required table
 
public void initValue()
{
    NumberSeq       NumSeq;
    ;
    super();
    NumSeq =  NumberSeq::newGetNum(CustTable::numRefcarid(),true); //Your Table:: your method
    this.Car Id= NumSeq.num();  // your field name (EDT)

}

create a new method to get NumRefID

public client server static NumberSequenceReference numRefcarid()
{
    ;

    return NumberSeqReference::findReference(extendedTypeNum(carid)));
}
 

Running Values In Report

If you want to check the running balance how does it work create a report 
Eg:
take Custtrans
after finishing the steps in  Morphx environment  (dp class , contract class, menuitem)

Add the fields in Visual studio  AccountNum  , Transdate , AmountCur
again again the extra field to it and name it as  Running value 
 
 


Add the expression in  Running value 


After deploying in Visual Studio
now you can see the result 

Wednesday 22 February 2017

Amount in Words (Report)


1. Declare a real variable in class  declaration    real  Amount;
2. use this code at the end of insert Method //( Dp class)
  Amount  += inventjournaltrans.CostAmount; //(Mapping)
3. and update Tmptable at the end of process report method.
   update_recordSet  TmpTable setting
    AmountInWords =Global::numeralsToTxt(Amount  );//Assigning the field to translate the text       format