Skip to content

Instantly share code, notes, and snippets.

@elchele
Created May 23, 2018 00:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save elchele/1f4aa6e396ffe610be839346a291e0fd to your computer and use it in GitHub Desktop.
Save elchele/1f4aa6e396ffe610be839346a291e0fd to your computer and use it in GitHub Desktop.
Invoking code on a successful response
myCustomJSMethod: function(module, guid){
//Instantiate a SugarBean object representing record identified by GUID
var beanObject = app.data.createBean(module, {id:guid});
//Send request to REST v10 API to retrieve the record
beanObject.fetch({
//Define the anonymous function that will execute on a successful response
success: function(data){ //the data parameter represents the JSON response from the API
//Do something with the response upon successful request
console.log(data); //This will simply output response to JS console
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment