Some times on the form we need to check which object called this form and based on the calling object we do some changes on the form.
if the type of the calling object is class than below is the code inside if check through which we can identify the name of the caller class:
if(SysDictClass::isEqualorSuperclass(classidget(element.args().caller()), classnum(nameoftheclass)))
{
//write some logic to do some changes on the form if the caller class is the same is you check
}
if the type of the calling object is menuitem than below is the code:
if(this.formRun().args().menuItemName() == (menuItemDisplayStr(HcmUpdateToForecastPosition))
{
//write some logic to do some changes on the form if the caller menuitem is the same as you check
}
if the type of calling object is form than below is the code:
Object formRunObject;//write this in the class declaration of the form
//write below code in the init method of the form
formRunObject = element.
if (element.args().caller())
{
formRunObject = element.args().caller();
if(formRunObject.name() == formstr(ProjInvoiceTable))
{
//write some logic to do some changes on the form if the caller menuitem is the same as //you check
}
}
This are the three ways in which we can check the names of calling object.
you can write these code in the init method.
if you have any questions on this than feel free to comment on it.
Thanks
Muhammad Zahid
if the type of the calling object is class than below is the code inside if check through which we can identify the name of the caller class:
if(SysDictClass::isEqualorSuperclass(classidget(element.args().caller()), classnum(nameoftheclass)))
{
//write some logic to do some changes on the form if the caller class is the same is you check
}
if the type of the calling object is menuitem than below is the code:
if(this.formRun().args().menuItemName() == (menuItemDisplayStr(HcmUpdateToForecastPosition))
{
//write some logic to do some changes on the form if the caller menuitem is the same as you check
}
if the type of calling object is form than below is the code:
Object formRunObject;//write this in the class declaration of the form
//write below code in the init method of the form
formRunObject = element.
if (element.args().caller())
{
formRunObject = element.args().caller();
if(formRunObject.name() == formstr(ProjInvoiceTable))
{
//write some logic to do some changes on the form if the caller menuitem is the same as //you check
}
}
This are the three ways in which we can check the names of calling object.
you can write these code in the init method.
if you have any questions on this than feel free to comment on it.
Thanks
Muhammad Zahid
What if we want to check for the caller form's/object's caller form and then apply the condition. For example Form A Calls> Form B calls > Form C we want to check in form C whether it was called from Form A?
ReplyDeleteI am not sure if there is a direct way of checking Form A from From C. What you can do is you can check the Form A on Form B init method using the code define above and then pass some info of form A in the arguments and pass those arguments to form C and on form C init method check the arguments values based on that decide if the form b was called from form A or not.
Delete