V7 plugin code for "FormObject.mRecordSave_Click()"  Topic is solved

Discussions relating to plugin development, and the Jiwa API.

V7 plugin code for "FormObject.mRecordSave_Click()"

Postby dimuthu » Tue Feb 10, 2015 2:38 pm

Could you please tell me what is the V7 sales order plugin code for "FormObject.mRecordSave_Click()" ( I used this in 'Sales Order Read Completed ' V6 breakout code )

I tried "salesOrderForm.SaveRecord()" in ReadEnd event in the plugin. But when i open the sales order form it didn't load. When i remove this code it loaded.

Following are my code sample

Private salesOrderForm As JiwaSalesUI.SalesOrder.SalesOrderEntryForm

Public Sub Setup(ByVal JiwaForm As JiwaApplication.IJiwaForm, ByVal Plugin As JiwaApplication.Plugin.Plugin) Implements JiwaApplication.IJiwaFormPlugin.Setup
salesOrderForm = DirectCast(JiwaForm, JiwaSalesUI.SalesOrder.SalesOrderEntryForm)
AddHandler salesOrderForm.SalesOrder.ReadEnd, AddressOf SalesOrderReadCompleted
End Sub

Public Sub SalesOrderReadCompleted(sender As Object, e As System.EventArgs)
try
' my coding
Finally
salesOrderForm.SaveRecord
End Try
End Sub

Regards
Dimuthu
dimuthu
Occasional Contributor
Occasional Contributor
 
Posts: 34
Joined: Fri Feb 06, 2015 3:03 pm

Re: V7 plugin code for "FormObject.mRecordSave_Click()"

Postby Scott.Pearce » Wed Feb 11, 2015 8:01 am

Try:

Code: Select all
salesOrderForm.SalesOrder.Save
Scott Pearce
Senior Analyst/Programmer
Jiwa Financials
User avatar
Scott.Pearce
Senpai
Senpai
 
Posts: 742
Joined: Tue Feb 12, 2008 11:27 am
Location: New South Wales, Australia
Topics Solved: 221

Re: V7 plugin code for "FormObject.mRecordSave_Click()"

Postby dimuthu » Wed Feb 11, 2015 10:28 am

Hi Scott,

Thanks for the reply. I tried that but same result. Order form didn't open and after sometime it throws the attached error message. When i commented that code part , form loaded.

Regards
Dimuthu
Attachments
V7Error.jpg
V7Error.jpg (35.05 KiB) Viewed 2520 times
dimuthu
Occasional Contributor
Occasional Contributor
 
Posts: 34
Joined: Fri Feb 06, 2015 3:03 pm

Re: V7 plugin code for "FormObject.mRecordSave_Click()"  Topic is solved

Postby Scott.Pearce » Wed Feb 11, 2015 11:12 am

Ah.

Saving causes the business logic object to re-read itself, so you are in an infinite loop:

Sales order is read -> Your code does sales order save -> this causes a sales order read -> this causes your code to do a sales order save -> and so-on forever.

You need to set a flag of some sort when your plugin does the save, so it knows not to run again for the next read. Here is what I mean:

Code: Select all
   Private salesOrderForm As JiwaSalesUI.SalesOrder.SalesOrderEntryForm

   Public Sub Setup(ByVal JiwaForm As JiwaApplication.IJiwaForm, ByVal Plugin As JiwaApplication.Plugin.Plugin) Implements JiwaApplication.IJiwaFormPlugin.Setup
      salesOrderForm = DirectCast(JiwaForm, JiwaSalesUI.SalesOrder.SalesOrderEntryForm)
      AddHandler salesOrderForm.SalesOrder.ReadEnd, AddressOf SalesOrderReadCompleted
   End Sub

   Public Sub SalesOrderReadCompleted(sender As Object, e As System.EventArgs)
      Static pluginSave As Boolean
      
      If pluginSave Then
         Exit Sub
      End If
      
      pluginSave = True
      
      Try
      
      ' my coding
      
      salesOrderForm.SaveRecord
      
      Finally   
         pluginSave = False
      End Try
   End Sub


Note that I've had to move your SaveRecord call out of the Finally, because we don't always want it to happen.
Scott Pearce
Senior Analyst/Programmer
Jiwa Financials
User avatar
Scott.Pearce
Senpai
Senpai
 
Posts: 742
Joined: Tue Feb 12, 2008 11:27 am
Location: New South Wales, Australia
Topics Solved: 221

Re: V7 plugin code for "FormObject.mRecordSave_Click()"

Postby dimuthu » Wed Feb 11, 2015 4:48 pm

Thanks Scott. It worked.

Regards
Dimuthu
dimuthu
Occasional Contributor
Occasional Contributor
 
Posts: 34
Joined: Fri Feb 06, 2015 3:03 pm


Return to Technical and or Programming

Who is online

Users browsing this forum: Bing [Bot] and 2 guests

cron