Skip to main content
Nintex Community Menu Bar
Question

Is it possible to add a Custom Salesforce Button from an installed package to a skuid page? The but

  • Jul 11, 2024 1:10 PM UTC
  • 9 replies
  • 88 views
  • Translate All

Forum|alt.badge.img+2

Is it possible to add a Custom Salesforce Button from an installed package to a skuid page?  The button is an Execute JavaScript

This topic has been closed for replies.

9 replies

Forum|alt.badge.img+10

Jake,

Add a Button Set or Page Title component to your page.  Then add a button and select ‘Custom: SF Button/Link’ as the Button Type.  Your button should show in the Custom Button / Link Name option.

Thanks,

Bill

Translate

Forum|alt.badge.img+2

Thanks Bill!  Looks like no OnClick JavaScript buttons are available with the above steps, it is a button of Type = List Button with Content Source = OnClick JavaScript.  It is a button that is from an installed package we purchased.

Translate

Forum|alt.badge.img+10

Jake,

Skuid would not be able to run the buttons with OnClick JavaScript.  Most of these types of buttons only have a little bit of ‘code’ in them.  Much of this code isn’t needed with Skuid.  You can ‘rebuild’ the button using Skuid actions most of the time.

If you need code, the script usually ‘translates’ to Skuid pretty well.  Here is a link where Rob Hatch rebuilt an OnClick JavaScript as a snippet:

https://community.skuid.com/t/could-any-one-help-me-to-change-salesforce-javascript-execu…

Would you post the JavaScript from the button.  I can take a look.

Thanks,

Bill

Translate

Forum|alt.badge.img+17
  • Nintex Employee
  • Jul 11, 2024 1:37 PM UTC

Thanks for the shout out Bill… 

Translate

Forum|alt.badge.img+2

Thanks bill, I’ll post JavaScript in below comment.

Translate

Forum|alt.badge.img+2
&#47;&#47; create the form&#46; Set it up to POST the transaction f = document&#46;createElement("form"); f&#46;action="<a href="https://toutapp.com/components/add_to_campaign" rel="nofollow" target="_blank" title="Link: https://toutapp.com/components/add_to_campaign">https:&#47;&#47;toutapp&#46;com/components/add_to&#46;&#46;&#46;</a>"; f&#46;method = "post"; f&#46;target = "_blank"; &#47;&#47; add the session id as a parameter i = document&#46;createElement("input"); i&#46;id = "session"; i&#46;name = "session"; i&#46;type = "hidden"; i&#46;value = "{!API&#46;Session_ID}"; f&#46;appendChild(i); &#47;&#47; add the server location as a parameter i = document&#46;createElement("input"); i&#46;id = "server"; i&#46;name = "server"; i&#46;type = "hidden"; i&#46;value = "{!API&#46;Partner_Server_URL_90}"; f&#46;appendChild(i); &#47;&#47; Get the Object IDs that were checked idArray = {!GETRECORDIDS($ObjectType&#46;Contact)}; if(idArray&#46;length &gt; 0) { &#47;&#47; add the idArray as a parameter i = document&#46;createElement("input"); i&#46;id = "ids"; i&#46;name = "ids"; i&#46;type = "hidden"; i&#46;value = idArray; f&#46;appendChild(i); &#47;&#47; add the object type i = document&#46;createElement("input"); i&#46;id = "object_type"; i&#46;name = "object_type"; i&#46;type = "hidden"; i&#46;value = "Contact"; f&#46;appendChild(i); &#47;&#47; add the form to the document&#46; document&#46;body&#46;appendChild(f); var w = window&#46;open("", "MySubWindow", "height=435,width=648"); f&#46;target = "MySubWindow"; &#47;&#47; submit the form f&#46;submit(); } else { alert("Please select at least one Contact to add to a Tout Campaign&#46;"); }
Translate

Forum|alt.badge.img+10

Jake,

Will you add this button to a page with a table of Contacts?  It looks like the code was setup to use contacts ‘selected’ in a table (what Skuid calls a Mass Action).  The reason for asking is that it changes how you would get the Contact Ids to put into the form submit.

The good news is that this script only needs a few changes.

Thanks,

Bill

Translate

Forum|alt.badge.img+2

Correct, it is a table of Contacts with fields from Accounts as well.  So 3 models: Contacts, Accounts, User (to pull in Contacts/Accounts they own)

Translate

Forum|alt.badge.img+10

Jake,

This is a sample page with the script included as a mass action on the table. You will need to find the DOM element ‘Id’ of your table. I changed mine to ‘contactTable’.

Thanks,

Bill

<skuidpage unsavedchangeswarning="yes" personalizationmode="server" useviewportmeta="true" showsidebar="true" showheader="true" tabtooverride="Contact">
    <models>
        <model id="Contact" limit="100" query="true" createrowifnonefound="false" datasource="salesforce" sobject="Contact">
            <fields>
                <field id="FirstName"/>
                <field id="LastName"/>
                <field id="CreatedDate"/>
                <field id="Id"/>
            </fields>
            <conditions/>
            <actions/>
        </model>
    </models>
    <components>
        <pagetitle model="Contact" uniqueid="sk-lNF-199">
            <maintitle>
                <template>{{Model.labelPlural}}</template>
            </maintitle>
            <subtitle>
                <template>Home</template>
            </subtitle>
            <actions>
                <action type="savecancel" uniqueid="sk-lNF-197"/>
            </actions>
        </pagetitle>
        <skootable showconditions="true" showsavecancel="false" searchmethod="server" searchbox="true" showexportbuttons="false" pagesize="10" createrecords="true" model="Contact" mode="read" allowcolumnreordering="true" uniqueid="contactTable">
            <fields>
                <field id="FirstName" hideable="true" allowordering="true" uniqueid="fi-lN9-939"/>
                <field id="LastName" hideable="true" allowordering="true" uniqueid="fi-lN9-940"/>
                <field id="CreatedDate" hideable="true" allowordering="true" uniqueid="fi-lN9-941"/>
            </fields>
            <rowactions/>
            <massactions usefirstitemasdefault="true">
                <action type="multi" label="Send to Toutapp" icon="sk-icon-import">
                    <actions>
                        <action type="custom" snippet="openToutapp"/>
                    </actions>
                </action>
            </massactions>
            <views>
                <view type="standard"/>
            </views>
            <searchfields/>
        </skootable>
    </components>
    <resources>
        <labels/>
        <css/>
        <javascript>
            <jsitem location="inlinesnippet" name="openToutapp" cachelocation="false">var params = arguments[0],
$ = skuid.$;
var sessionid = sforce.connection.sessionId;
var partnerurl = sforce.connection.partnerServerUrls[9];
console.log('sessionid');
console.log(sessionid);
console.log('partnerurl');
console.log(partnerurl);
var selected = skuid.component.getById("contactTable");
var items = selected.list.getSelectedItems();
console.log("items");
console.log(items);
// create the form. Set it up to POST the transaction 
f = document.createElement("form"); 
f.action="<a href="https://toutapp.com/components/add_to_campaign&quot;">https://toutapp.com/components/add_to_campaign"</a>; 
f.method = "post"; 
f.target = "_blank"; 
// add the session id as a parameter 
i = document.createElement("input"); 
i.id = "session"; 
i.name = "session"; 
i.type = "hidden"; 
i.value = sessionid; 
f.appendChild(i); 
// add the server location as a parameter 
i = document.createElement("input"); 
i.id = "server"; 
i.name = "server"; 
i.type = "hidden"; 
i.value = partnerurl; 
f.appendChild(i); 
// Get the Object IDs that were checked 
//idArray = {!GETRECORDIDS($ObjectType.Contact)}; 
var idArray=[];
for (var i=0; i &amp;lt; items.length; i++) {
        idArray.push(items[i].row.Id);
}
console.log('idArray');
console.log(idArray);
if(idArray.length &amp;gt; 0) { 
    // add the idArray as a parameter 
    i = document.createElement("input"); 
    i.id = "ids"; 
    i.name = "ids"; 
    i.type = "hidden"; 
    i.value = idArray; 
    f.appendChild(i); 
    
    // add the object type 
    i = document.createElement("input"); 
    i.id = "object_type"; 
    i.name = "object_type"; 
    i.type = "hidden"; 
    i.value = "Contact"; 
    f.appendChild(i); 
    
    // add the form to the document. 
    document.body.appendChild(f); 
    var w = window.open("", "MySubWindow", "height=435,width=648"); 
    f.target = "MySubWindow"; 
    // submit the form 
    f.submit(); 
} else { 
    alert("Please select at least one Contact to add to a Tout Campaign."); 
}</jsitem>
        </javascript>
        <actionsequences uniqueid="sk-lNF-248"/>
    </resources>
    <styles>
        <styleitem type="background" bgtype="none"/>
    </styles>
</skuidpage>
Translate