Thursday, September 15, 2022

Enable/Disable form control based on multiple rows select

 class PurchTableFormEventHandler

{

     [FormDataSourceEventHandler(formDataSourceStr(PurchTable, PurchTable), FormDataSourceEventType::Activated)]

    public static void PurchTable_OnActivated(FormDataSource sender, FormDataSourceEventArgs e)

    {

        FormRun             formRun = sender.formRun();

        FormRun             element       = sender.formRun(); 

        FormControl         yourcontroller = element.design(0).controlName("yourcontrollerName");       

        FormDataSource  PurchTable_ds = formRun.dataSource(formDataSourceStr(PurchTable, PurchTable));

        PurchTable PurchTable ;

        PurchTable = PurchTable_ds.getFirst(true) ? PurchTable_ds.getFirst(true) : PurchTable_ds.cursor();

      

        while(purchTable)

        {

            if(purchTable.DocumentState == VersioningDocumentState::Confirmed &&

                purchTable.PurchStatus != PurchStatus::Canceled)

            {

                 yourcontrollerName.enabled(true); 

            }

            else

            {

                yourcontrollerName.enabled(false);

                break;

            }

            purchTable = PurchTable_ds.getNext() as PurchTable;

        }        

    }

}

Friday, June 10, 2022

Validate Number's in String column

public boolean validateHSN()

{

    boolean ret = true;

    int     i = strLen(this.HSNCode);

    TextBuffer txt = new TextBuffer();

    str msg = this.HSNCode;


    txt.setText(msg);

    txt.regularExpressions(true);


    if (ret)

    {

        if (i == 4 || i == 6 || i == 8)

        {

            ret = true;

        }

        else

        {

            ret = checkFailed("Enter 4 0r 6 or 8 digits only");

        }

    }

     if (ret)

    {

        if (txt.find("^[0-9]+$"))

        {

            ret = true;

        }

        else

        {

            ret = checkFailed("Enter only numbers");

        }

    }

    return ret;

}

Tuesday, December 28, 2021

Refresh form datasource from Class

 Auto Refresh form after uploaded data 

in Class main method 

static client void main(Args   _args)

{

YourClassName          testclass;

FormDataSource     callerds; 

;

testclass = new  YourClassName();

if(_args && _args.record() && _args.record().isFormDataSource())

{

    callerds = _args.record().DataSource();

}

    testclass.run();


//Refresh form DS

callerds.research();

}






Friday, November 26, 2021

get selected record from Lookup



based on selected record from parent code lookup modify item id in purchase order.

create a new custom lookup form as shown below.


override closeselect   method :

Public void closeselect(str  _selectString)
{
FormRun      formrun;
Object          formrunobj;

     super(_selectString);

if(element.args() != null
    && element.args().caller() != null
   && SysDictClass::is(element.args().caller(),classnum(FormRun ))
    {
        formrun = element.args().caller();
        if(formHasMethod(formrun,identifierstr(PurchTable)))
        {
          formrunobj = formrun;
        }
}

}

override init method :

set  Autodeclaration Yes Highlited control in 

Public void int()
{
    super();
    element.selectMode(InventTable_ParentCode);
}

override runmethod :

Public void run()
{
    FormStringControl         callingcontrol;
    boolean                           filterlookup;
    FormRun                        formrun;
        
   if(element.args()  && element.args().caller())
    {
        if(SysDictClass::is(element.args().caller(),classnum(FormRun )))
        {
            formrun =  element.args().caller();
        }
    super();
    
}

call Lookup form in ParentCode control level in PurchTable form.

Public void lookup()
{
      Args       args = new Args();
     FormRun      lookupform;
    InventTable       inventTable;

    args.name(formstr(parentlookup));
    args.parm(PurchLine.ItemId);

    lookupform = new FormRun(args);
    lookupform .init();
    this.performFormLookup(lookupform);
    lookupform.wait();

    if(lookupform.closeOk())
    {
        inventTable = lookupform.docCursor();
    }

}

Get RecId from inventTable modify ItemId from modified method.

Wednesday, August 18, 2021

ComboBox filter

1. Add Enum control in Form

2 .Enum Contol AutoDeclaration property set to Yes. 

3 .in control modified method add below code.

public boolean modified()

{

     int                                ret;

    QueryBuildRange       range;

    ;

    ret = super();

    range = SysQuery::findOrCreateRange(
        purchTable_DS.query().dataSourceTable(tablenum(PurchTable)),
        fieldnum(PurchTable, PurchStatus));
    range.value(queryValue(controlname.selection()));
    purchTable_DS.executeQuery();

    return ret;
}

Friday, June 18, 2021

Some Important function

 Get Last Two Characters

Str     s = 'AXAPTA';

info(strfmt( subStr(s,strLen(s)-1,strlen(s)));

OutPut : TA

Get First Two Characters

info(strFmt(subStr(s,0,2 )));

OutPut : AX

Friday, December 4, 2020

Validate in UI Builder class

 Write below code in your UIBuilder Class

public boolean validatePostingProfile(FormStringControl  _control)

{

    boolean        ret = true;

   VendPostingProfile    vendPostingProfile;

    vendPostingProfile  = _control.valueStr();  

    if(VendLedger::find(vendPostingProfile))

    {

        if(vendPostingProfile != ' ' )

        {

        error ('Posting profile does not exist');

        ret = false;

    }

    return ret;

}


call the above method in PostBuild  method


dlgpostingProfile.registerOverrideMethod(methodStr(FormStringControl, validate), methodStr(<yourUIBuilderclass>, validatePostingProfile),this);

Enable/Disable form control based on multiple rows select

 class PurchTableFormEventHandler {      [FormDataSourceEventHandler(formDataSourceStr(PurchTable, PurchTable), FormDataSourceEventType::Act...