How to pass parameters from SalesTable form to salesFormLetter_Confirm Class

Hi

I want to pass parameter from Salestable Form to the initJournal method of SalesFormLetter_Confirm.
I could pass parameter from Salestable Form to the main of SalesFormletter using this:

in the clicked method of a menuitemButton that call the class : SalesFormLetter in the form I wrote this :

void clicked()
{

boolean ProformaOk;
Args args = new Args();
;
element.args().parm(‘OK’);
super();
}
and in the main of SalesFormLetter Class I wrote this and I got the rignt value.

formrun fr;

;

if (! args)
throw error("@SYS25407");

fr = args.caller();

if( fr.args().parm() == ‘OK’)
{
Proforma = Noyes::Yes;
}

SalesFormLetter_Confirm. extends from SalesFormLetter , it has no main method , there is no args in the initJournal method. I wonder how to do to pass the parameter either directely to the salesFormLetter_Confirm or by passing through the parent class : SalesFormLetter.

Thanks very much for helping!

You can create a variable in the classDeclaration of SalesFormLetter and then store that parm value if you want. Then from SalesFormLetter_Confirm, you should be able to access it. I would try a different method than passing the variable though.

Hi

Thanks for your response [:)]

I tried this and it works

in the main of SalesFormLetter Class

container cachedArgs;

globalCache = ClassFactory.globalCache();
//
fr = args.caller();

if( fr.args().parm() == ‘OK’)
{
Proforma = Noyes::Yes;
}
globalCache.set(curuserid(), 1, Proforma);

and in the initJournal method of SalesFormLetter_Confirm

globalCache = ClassFactory.globalCache();

proforma = globalCache.get(curuserid(), 1);

What optimized solution would you suggest?

What you are doing is going against the design of the SalesFormLetter classes. I wouldn’t put anything in the main method, but instead in the mainOnServer method, because that is where the SalesFormLetter is actually instantiated.

You need to create a parm method and a variable in the classDec too obviously. And you should only need in your button clicked method, element.args().parm(‘OK’); and not some of the other stuff.

I’d need to know what you are actually trying to accomplish to try and think of a better method…but it seems like you could create a new menu item with a different enum param or something.

Hi

I understand , I thought of doing so but for my work consists on creating an invoice similar to confirmation invoice, the process is the same as SalesFormLetter_Confirm , I need just to add a field to distinguish between the two docuementStatus of the two invoices I thought it would be easier to add this field and check it in the main method.

I think you’re right I’ve changed the design of the SalesFormLetter classes.

Thank you for your advice.