Oct 30, 2012

How to get caller form name ?


This is an example for enabling and disabling of button1 and button2  on basis of caller form

Public void buttonEnable()
{
    UserGroupList           userGroupList,userGroupList1;
    ProjParameters          projParameters;
    formRun                    caller;
    ;
    caller = element.args().caller(); // caller form

    if(caller.args().name() == formStr(ProjTable)) // caller form name
    {
        projParameters = ProjParameters::find();
        
       // Checking that the CurUserId() is there of one particular group or not

        Select userGroupList where userGroupList.UserId == curUserId()
                                   && userGroupList.groupId == projParameters.SalesAcceptanceChangeOrder;
        if(userGroupList)
        {
            Button1.enabled(true);
        }
        else
        {
            Button1.enabled(false);
        }
        Select userGroupList1 where userGroupList1.UserId == curUserId()
                                   && userGroupList1.groupId == projParameters.CommercialAcceptanceChangeOrder;
        if(userGroupList1)
        {
            Button2.enabled(true);
        }
        else
        {
            Button2.enabled(false);
        }
    }
    if(caller.args().name() == formStr(ProjQuoteTable))
    {
        projParameters = ProjParameters::find();

        Select userGroupList where userGroupList.UserId == curUserId()
                                   && userGroupList.groupId == projParameters.SalesAcceptanceQtn;
        if(userGroupList)
        {
            Button1.enabled(true);
        }
        else
        {
            Button1.enabled(false);
        }
        Select userGroupList1 where userGroupList1.UserId == curUserId()
                                   && userGroupList1.groupId == projParameters.CommercialAcceptanceQtn;
        if(userGroupList1)
        {
            Button2.enabled(true);
        }
        else
        {
            Button2.enabled(false);
        }
    }

}