How to add a button to call drawloop in skuid

  • 1
  • Question
  • Updated 3 years ago
  • Answered
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('<button> Create Contract</button>').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);
});
Photo of Namrata

Namrata

  • 332 Points 250 badge 2x thumb

Posted 3 years ago

  • 1
Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb
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.
Photo of Rob Hatch

Rob Hatch, Official Rep

  • 44,006 Points 20k badge 2x thumb
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. 
Photo of Namrata

Namrata

  • 332 Points 250 badge 2x thumb
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.. 
Photo of Namrata

Namrata

  • 332 Points 250 badge 2x thumb
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}}&sessionId={{$Api.Session_Id}}&autorun=true";
        var merges = skuid.$('<div>').append(appModel.mergeRow(appRow,url));
        window.open(merges.text());
Photo of Rob Hatch

Rob Hatch, Official Rep

  • 44,006 Points 20k badge 2x thumb
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. 
Photo of Greg Jarrett

Greg Jarrett

  • 3,496 Points 3k badge 2x thumb
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.

Photo of Namrata

Namrata

  • 332 Points 250 badge 2x thumb
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.
Photo of Rob Hatch

Rob Hatch, Official Rep

  • 44,006 Points 20k badge 2x thumb
Namrata - I'm glad you got things working.