cancel
Showing results for 
Search instead for 
Did you mean: 

How to check if user has saved most recent changes via script?

Former Member
0 Kudos

We have a requirement for a pre-publish script for Publish Supplier to ERP. This script calls a third-party web service when the user clicks Publish Supplier button (this replaces the standard flow).

Now if the user has made any changes to the Supplier and clicks Publish button, then a standard error message is displayed telling the user to save the changes first ("Supplier has been modified. Please save the changes before publishing the supplier."). The problem I am facing is that my Prepublish script gets called before this validation.. so the web service is triggered and then after the user saves changes and publishes again, the web service is triggered a second time with the same set of data. I want to prevent this duplicate call by including the "Save your changes first" validation in my custom script.. please suggest how I can find out if a document is saved or not

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

I hit couple of other validations as well that are run after my custom Pre Publish script..some of them are "You can publish only suppliers with status 'To Be Replicated'", "An account group must be selected to publish a supplier", "The External ID must be without leading zeroes to publish a supplier"

How can I make the system run these validations before the custom script so that the 3rd party web service is called only once with the validated data?

Former Member
0 Kudos

I could not find any way to make the validations run before my prepublish script or to check for unsaved changes on the Vendor object. As a workaround, I have replicated all the system level validations in my custom script and if all validations pass, I force a save using save method in Vendor Home like this:

vendorHome=IBeanHomeLocator.lookup(session,VendorIBeanHomeIfc.sHOME_NAME);

vendorHome.save(doc);

I feel this behaviour is a bug in SAP Sourcing code. Ideally the system should perform all validations that it intends to do and if everything is fine then only it should call the Prepublish to ERP script. Currently it calls the script and then executes some of the validations, leading to the error situation I faced. Can anyone from SAP please give your view on this?