Showing results for 
Search instead for 
Do you mean 
Community Home Request Access Read Blogs Share Your Ideas Search Community View My Settings
Reply
Highlighted
Copper Super Contributor
Posts: 172
Registered: ‎07-06-2010

Hooking into Save event for a custom Edit view

[ Edited ]

Can anyone recommend a tutorial or code sample location to demonstrate tapping into the Save event for a View in SlxMobile 2.0 for 7.5.4?

 

I have a view that, when saving a change to a property on Opportunity, needs to communicate with a web service. I can put together the web service post code already, but I am not sure how to wire it up so that it is called when the user clicks Save in the toolbar.

Employee
Posts: 51
Registered: ‎12-16-2011

Re: Hooking into Save event for a custom Edit view

[ Edited ]

In your edit view, you can override the base SDK Edit's save:

 

save: function() {

    this.inherited(arguments);

    // Your webservice code here

}

 

EDIT:

If you need to ensure the data has updated/inserted correctly, you can instead override onInsertSuccess or onUpdateSuccess instead.

Copper Super Contributor
Posts: 172
Registered: ‎07-06-2010

Re: Hooking into Save event for a custom Edit view

[ Edited ]

Thanks. Is this the right place to extend the Account save code, for example?

 

In our web implementation we have combined the Insert Account/Contact pages so that a primary Contact is created when an account is made. In Mobile this doesnt happen. I wanted to extend the Account save function to create the dependent record.

 

I think we can use OnInsertSuccess, but wondring if there's a better place/way to do this. Thanks.

Employee
Posts: 51
Registered: ‎12-16-2011

Re: Hooking into Save event for a custom Edit view

The SDK's edit view publishes a global pub/sub event when an insert or update occurs:

 

https://github.com/Saleslogix/argos-sdk/blob/develop/src/Edit.js#L1075

 

You can subscribe to this event in your case.