Hi team,
I wrote below code to enable or disable the buton.
class SalesInvoiceOrgActiveEventHandlers { ////// to enable or disbale SalesInvoiceOriginal button based on setup in Cust parameter. /// /// /// [FormDataSourceEventHandler(formDataSourceStr(CustInvoiceJournal, CustInvoiceJour), FormDataSourceEventType::Activated)] public static void CustInvoiceJour_OnActivated(FormDataSource sender, FormDataSourceEventArgs e) { #Define.SalesInvoiceOriginal('SalesInvoiceOriginal') CustInvoiceDuplicateTable_W custInvoiceDuplicateTable_W; CustInvoiceJour custInvoiceJour = sender.cursor(); FormRun element = sender.formRun(); FormControl SalesInvoiceOriginal = element.design(0).controlName(#SalesInvoiceOriginal); FormDataSource custInvoiceJour_ds; CustParameters custParameters = CustParameters::find(); // This condition is to added to control the SalesInvoiceOriginal button to get disable once the report got executed for 1st time // for the current record. if (custParameters.RestrictOrgPreview == NoYes::Yes && custInvoiceJour.OrgPreviewPrint == NoYes::Yes) { SalesInvoiceOriginal.enabled(false); } else { SalesInvoiceOriginal.enabled(true); } } }
The button is working fine for enabled or disbaled. Once I refreshed the form then only it work properly.
I am looking for enabled or disabled the button without refreshing the form. Kindly let me know what to do?
Please give me more shed on this.
thanks!
Yes Mohit, I tried it is working fine.
thanks to all of you again
You don't need to refresh the database, please try adding below code to disable the button. And code on active method will then enable or disable it for other records based on OrgPreviewPrint field value.
[FormControlEventHandler(formControlStr(CustInvoiceJournal, SalesInvoiceOriginal), FormControlEventType::Clicked)] public static void SalesInvoiceOriginal_OnClicked(FormControl sender, FormControlEventArgs e) { sender.enabled(false); }
Hi Mohit,
The code to update RestrictOrgPrevie to Yes
[ExtensionOf(formControlStr(CustInvoiceJournal, SalesInvoiceOriginal))] final class CustInvoiceJourSalesInvoiceOriginal_Extension { CustParameters custParameters; CustInvoiceJour custInvoiceJour; custParameters = CustParameters::find(); if (custParameters.RestrictOrgPreview == NoYes::Yes) { ttsbegin; select forupdate custInvoiceJour where custInvoiceJour.InvoiceId == custInvoiceJourSelected.InvoiceId; if (custInvoiceJour) { custInvoiceJour.OrgPreviewPrint = NoYes::Yes; custInvoiceJour.doUpdate(); } ttscommit; } }
yes already I tried. It may many records based on the condition in CustInvoiceJour table and same thing happened. So , I removed that.
Can you add that refresh thing in if and else condition?
Hi Baharani,
Recent code
class SalesInvoiceOrgActiveEventHandlers { ////// to enable or disbale SalesInvoiceOriginal button based on setup in Cust parameter. /// /// /// [FormDataSourceEventHandler(formDataSourceStr(CustInvoiceJournal, CustInvoiceJour), FormDataSourceEventType::Activated)] public static void CustInvoiceJour_OnActivated(FormDataSource sender, FormDataSourceEventArgs e) { #Define.SalesInvoiceOriginal('SalesInvoiceOriginal') CustInvoiceDuplicateTable_W custInvoiceDuplicateTable_W; CustInvoiceJour custInvoiceJour = sender.cursor(); FormRun element = sender.formRun(); FormControl SalesInvoiceOriginal = element.design(0).controlName(#SalesInvoiceOriginal); FormDataSource custInvoiceJour_ds = sender; CustParameters custParameters = CustParameters::find(); // This condition is to added to control the SalesInvoiceOriginal button to get disable once the report got executed for 1st time // for the current record. if (custParameters.RestrictOrgPreview == NoYes::Yes && custInvoiceJour.OrgPreviewPrint == NoYes::Yes) { SalesInvoiceOriginal.enabled(false); } else { SalesInvoiceOriginal.enabled(true); } /*custInvoiceJour_ds.research();*/ } }
Hi all,
I have chacked in CutInvoiceJournal.extension form , SalesInvoiceJournal button property "AutoRefreshData" this is also non editable. it's locked
Pls give me more shed on this.
thanks!
Can you show the present code which you have written till now?
Hi All
I tried, with ds.research() after if condition . but the issue is when I am trying open the Invoice Journal form it is gone totally hanged. not opening.
when I coment my code, then the form get opened.
pls give me more shed on this.
thansk!
Understood Girish. Thank you.
Exactly try using research as I said earlier. That does the same job as the soft refresh.
So try ds.research();
André Arnaud de Cal...
292,031
Super User 2025 Season 1
Martin Dráb
230,868
Most Valuable Professional
nmaenpaa
101,156