What is the Syntax for Re-querying a model inside JavaScript Snippet??

  • 3
  • Question
  • Updated 2 years ago
  • Answered
What is the Syntax for Re-querying a model inside JavaScript Snippet??  I want to requery a model inside the Snippet..Can anyone help me on this issue..
Photo of Vaibhav

Vaibhav

  • 308 Points 250 badge 2x thumb

Posted 2 years ago

  • 3
Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb
Photo of Vaibhav

Vaibhav

  • 308 Points 250 badge 2x thumb
Hi Matt, thank you for such a prompt response, can you please help me out with that particular snippet? I am calling a webservice Apex class which creates a new Record, I need to requery that model so that I can pick that newly created Record Id and redirect the user to that record automatically..
Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb
Assuming you have a model called MyModel and a condition on that model called 'IdConditionName' (which is a filterable default on condition where Id=''), you can do something like this:

var $ = skuid.$,
     model = skuid.$M('MyModel');
//var newRowId = whatever your class returns as the Id of the new row
model.setCondition(model.getConditionByName('IdConditionName'),newRowId);
$.when(model.updateData()).then(function(){
   //Do anything you need to do after the query here.
});
(Edited)
Photo of Vaibhav

Vaibhav

  • 308 Points 250 badge 2x thumb
Wow, Well Thank you so so much Matt, It worked beautifully. Thank you so much for the snippet. I really appreciate you coming up and helping me out.

Thanks Again!