Previously, I talked about a basic example of V7 Style coding here, and a question was asked, on how to add a button with method to a representation and I like to show a basic example of that here.
Before we get to the point of this blog, please review an online help entry titled, “Tip distinction between methods and operations and working in a stateless context” which is accessible in Sage X3 online help by searching for the title.
Based on the above online help entry you would learn what is the difference between a method vs an operation.
Now to the point of the example, here, I am going to add a button/link to my representation that will call a method with an information message also, another button that will call an operation. (If you need to know how to create the ZCLIENT example review the first blog)
- Open Development, Data and Parameters, Classes , Classes.
- Select ZCLIENT class.
- Go to Methods tab, and create a new line like below.
- Save and Validate.
- On the General tab, notice the name that is assigned to your class code.
- Open Development, Scripts Dictionary, Scripts, Script Editor.
- Enter the name of your Class script.
- Add the following Code.
################
$METHODS
Case [L]CURPTH
When ""
Case [L]ACTION
When "ZINFORMATION"
Gosub SHOW_INFORMATION
When "ZLISTINFORMATION"
Gosub SHOW_INFORMATION_OPERATION
Endcase
Endcase
Return
$PROPERTIES
Case [L]CURPRO
Endcase
Return######################
$SHOW_INFORMATION
[L]ASTATUS = fmet this.ASETERROR("", "This is a Method", [V]CST_AWARNING) ## this will show a message that this is a method
Return
##########
$SHOW_INFORMATION_OPERATION[L]ASTATUS = fmet this.ASETERROR("", "This is an Operation", [V]CST_AWARNING) ## this will show a message that this is an Operation
Return
- Save and Compile.
- Open Development, Data and parameters, Classes, Representations.
- Select ZCLIENT representation.
- Click on Links Tab.
- For the Anchor type select Record.
- Add a new link like below.
- The above is for a method link.
- Below is an example of operation link.
- Save and validate.
- Now when you launch your representation, in the query mode I have a link that point to my operation.
- By clicking on the link I would have the message as I expected.
- Similarly on the edit facet, I have my Method link.
- By clicking on this link I would have below.
Conclusion:
You can add a link to a representation and add code for it to call a method.
What is next:
In future blogs I will be talking about how you can manage two tables like a header and line, so stay tune for that