How to add a button to call drawloop in skuid

I am new to Skuid. I have added this Javascript Snippet to create a custom button. The onclick function of the button should call the drawloop ddp. I want to add this custom component in a tab. I cannot see the custom button… What might be the problem? Here is the Javascript snippet that I created. Thanks for your help.

skuid.componentType.register(‘GetContract’,function(element){

var btn = jQuery(’ Create Contract’).button()
.on(‘click’, function(){
//instantiate a model using “Applications model”
var appModel = skuid.model.getModel(‘applicationYod’);
//Get the first record from our model
var appRow = appModel.data[0];

    //Call Drawloop
    var url = "/apex/loop__looplus?eid={{Id}}&sessionId={{$Api.Session_Id}}&autorun=true";
    var merges = skuid.$('<div>').append(appModel.mergeRow(appRow,url));
    window.open(merges.text());
});
element.append(btn);

});

Namrata,

This should help: https://community.skuidify.com/skuid/topics/mass_action_inline_javascript_on_related_list_for_drawlo…

If you want, instead of building a custom component, you can just add a button to a pagetitle component and run an inline skuid javascript snippet from the button.

Yup, put your code in a snippet rather than in a custom button.  The snippet can be in a static resource for maximal reuse across a number of skuid pages.  Then a button on your Skuid page can trigger the snippet. 

Thanks for the help…I just tried to put use Page Title component and added a button which has action type as Custom: Run Skuid Snippet. But when I click on the button nothing happens. I expect the DDP screen to be displayed when I click on the button… 


I changed the above code to this… Any problem with the code?

//instantiate a model using “Applications”
var appModel = skuid.model.getModel(‘applicationYod’);
//Get the first record from our model
var appRow = appModel.data[0];

    //Call Drawloop

    var url = "/apex/loop__looplus?eid={{Id}}&amp;sessionId={{$Api.Session_Id}}&amp;autorun=true";
    var merges = skuid.$('<div>').append(appModel.mergeRow(appRow,url));
    window.open(merges.text());

Where is your snippett?  For testing add it to your skuid page as an “Inline Snippet”   Give it a name.  Add that name into the button definition properties. 

Just another approach here (and not necessarily the right one) but we managed this by building a standard salesforce button (as per the standard drawloop syntax to pass parameters in the button)…

and then deploying that button in Skuid using the ‘Custom SF Button/Link’ option in a Page Title component - see screenshot attached.

Thank you all for your suggestions. Greg, your approach was the quickest and easiest to implement. I also tried the Snippet option. It worked in the morning. But then I added a file upload component and it stopped working. So adding the salesforce button and accessing that thru Skuid was very helpful…

Thanks Again.

Namrata - I’m glad you got things working.