I am trying to concatenate id’s from one model into another model. On my account Id, I select a list of accounts, No I want to add the id’s of selected accounts onto a field in another model.
Just to make sure that I understand - you want to select accounts from a list then combine the list of Ids into a single field?
Yes, I want the account ids into a single field
Here’s one example of how to do it with mass select, adopting rows, and some row actions
<skuidpage unsavedchangeswarning="yes" personalizationmode="server" showsidebar="false" useviewportmeta="true" showheader="false">
<models>
<model id="Accounts" limit="20" query="true" createrowifnonefound="false" datasource="salesforce" sobject="Account">
<fields>
<field id="Id"/>
<field id="Name"/>
</fields>
<conditions/>
<actions/>
</model>
<model id="Accounts_Adopt" limit="20" query="false" createrowifnonefound="false" datasource="salesforce" sobject="Account">
<fields>
<field id="Id"/>
<field id="Name"/>
<field id="index" uionly="true" displaytype="FORMULA" label="index" ogdisplaytype="TEXT" readonly="true" returntype="DOUBLE" precision="9" scale="0">
<formula>{{index}}</formula>
</field>
<field uionly="true" displaytype="DOUBLE" id="currval" label="currval" ogdisplaytype="TEXT" precision="9" scale="0" defaultvaluetype="fieldvalue" defaultValue="0"/>
<field id="nextval" uionly="true" displaytype="FORMULA" label="nextval" ogdisplaytype="TEXT" readonly="true" returntype="DOUBLE" precision="9" scale="0">
<formula>{{currval}}+1</formula>
</field>
</fields>
<conditions/>
<actions>
<action>
<actions>
<action type="branch" whenfinished="stop">
<formula>{{index}}=={{currval}}</formula>
<iftrueactions>
<action type="updateRow" fieldmodel="Concat" affectedrows="context" field="Concat" enclosevalueinquotes="true" value="{{$Model.Concat.data.0.Concat}}{{Id}},"/>
<action type="abandonRows" model="Accounts_Adopt" affectedrows="context"/>
<action type="updateRow" model="Accounts" appendorprepend="prepend" defaultmodefornewitems="edit" affectedrows="all" fieldmodel="Accounts_Adopt" field="currval" enclosevalueinquotes="false" value="{{$Model.Accounts_Adopt.data.0.nextval}}"/>
</iftrueactions>
</action>
</actions>
<events>
<event>row.updated</event>
</events>
<fields>
<field>currval</field>
</fields>
</action>
</actions>
</model>
<model id="Concat" limit="20" query="true" createrowifnonefound="true" datasource="Ui-Only" processonclient="true">
<fields>
<field id="Concat" displaytype="TEXT" label="Concat"/>
</fields>
<conditions/>
<actions/>
</model>
</models>
<components>
<grid uniqueid="sk-1RBR-1706">
<divisions>
<division behavior="flex" minwidth="100px" ratio="1">
<components>
<skootable showconditions="true" showsavecancel="true" showerrorsinline="true" searchmethod="server" searchbox="true" showexportbuttons="false" hideheader="false" hidefooter="false" pagesize="10" alwaysresetpagination="false" createrecords="true" model="Accounts" buttonposition="" mode="read" allowcolumnreordering="true" responsive="true" uniqueid="sk-1R8C-408" heading="Accounts">
<fields>
<field id="Id" uniqueid="fi-1R8C-409"/>
<field id="Name" uniqueid="fi-1R8C-410"/>
</fields>
<rowactions>
<action type="edit"/>
<action type="delete"/>
</rowactions>
<massactions usefirstitemasdefault="true">
<action type="multi" label="Concat" icon="sk-icon-magic">
<actions>
<action type="custom" snippet="newSnippet"/>
<action type="adoptRows" sourcemodel="Accounts" targetmodel="Accounts_Adopt" affectedrows="context"/>
<action type="updateRow" fieldmodel="Accounts_Adopt" affectedrows="all" field="currval" enclosevalueinquotes="false" value="1"/>
</actions>
</action>
</massactions>
<views>
<view type="standard"/>
</views>
<actions defaultlabel="Global Actions" defaulticon="sk-icon-magic" usefirstitemasdefault="true"/>
</skootable>
</components>
</division>
<division behavior="flex" verticalalign="top" minwidth="100px" ratio="1">
<components>
<skootable showconditions="true" showsavecancel="false" showerrorsinline="true" searchmethod="server" searchbox="true" showexportbuttons="false" hideheader="false" hidefooter="false" pagesize="10" alwaysresetpagination="false" createrecords="false" model="Accounts_Adopt" buttonposition="" mode="readonly" allowcolumnreordering="true" responsive="true" uniqueid="sk-1RBT-1767" heading="Accounts Adopt">
<fields>
<field id="Id" uniqueid="fi-1RBT-1768"/>
<field id="Name" uniqueid="fi-1RBT-1769"/>
<field id="index" uniqueid="fi-1RBT-1770"/>
<field id="currval" hideable="true" uniqueid="fi-1RCt-2319"/>
<field id="nextval" hideable="true" uniqueid="fi-1RCu-2328"/>
</fields>
<rowactions/>
<massactions usefirstitemasdefault="true"/>
<views>
<view type="standard"/>
</views>
</skootable>
</components>
</division>
</divisions>
<styles>
<styleitem type="background" bgtype="none"/>
</styles>
</grid>
<skootable showconditions="true" showsavecancel="true" showerrorsinline="true" searchmethod="client" searchbox="true" showexportbuttons="false" hideheader="false" hidefooter="false" pagesize="10" alwaysresetpagination="false" createrecords="true" model="Concat" buttonposition="" mode="edit" allowcolumnreordering="true" responsive="true" uniqueid="sk-1R8S-559" heading="Concatenate">
<fields>
<field id="Concat" uniqueid="fi-1R8S-560"/>
</fields>
<rowactions>
<action type="edit"/>
<action type="delete"/>
</rowactions>
<massactions usefirstitemasdefault="true">
<action type="massupdate"/>
<action type="massdelete"/>
</massactions>
<views>
<view type="standard"/>
</views>
</skootable>
</components>
<resources>
<labels/>
<javascript>
<jsitem location="inlinesnippet" name="newSnippet" cachelocation="false">var params = argumentst0],
$ = skuid.$;
console.log(params);</jsitem>
</javascript>
<css/>
<actionsequences uniqueid="sk-3N03-382">
<actionsequence id="d5becc77-bad2-4efa-beb5-7924c60b3c26" label="OppsQuery" type="reusable" uniqueid="sk-1R88-357">
<description/>
<actions>
<action type="blockUI"/>
<action type="requeryModel" model="Opps" behavior="loadmore"/>
<action type="unblockUI"/>
</actions>
</actionsequence>
<actionsequence id="5cd052c7-9b17-4ef0-b17c-fe3761ba4adc" label="New Sequence" type="reusable" uniqueid="sk-1R88-358">
<description/>
<actions/>
</actionsequence>
</actionsequences>
</resources>
<styles>
<styleitem type="background" bgtype="none"/>
</styles>
</skuidpage>
Jaiti,
You can get all of the Id’s from a model using merge syntax. Note that I have included a comma next to the {{Id}}
{{#$Model.Accounts.data}}{{Id}},{{/$Model.Accounts.data}}
Here is an example page that uses this merge syntax along with a Formula field to remove the last comma from the merge ‘output’. Click the button ‘Get Ids’ to see this work.
<skuidpage unsavedchangeswarning="yes" personalizationmode="server" showsidebar="false" useviewportmeta="true" showheader="false">
<models>
<model id="Accounts" limit="20" query="true" createrowifnonefound="false" datasource="salesforce" sobject="Account">
<fields>
<field id="Id"/>
<field id="Name"/>
</fields>
<conditions/>
<actions/>
</model>
<model id="UIOnly" limit="20" query="true" createrowifnonefound="true" datasource="Ui-Only" processonclient="true">
<fields>
<field id="CleanIds" displaytype="FORMULA" label="CleanIds" ogdisplaytype="TEXT" readonly="true" returntype="TEXT">
<formula>LEFT({{FromActionIds}},(LEN({{FromActionIds}}) - 1))</formula>
</field>
<field id="FromActionIds" displaytype="TEXT" label="FromActionIds" length="5000"/>
</fields>
<conditions/>
<actions/>
</model>
</models>
<components>
<grid uniqueid="sk-1RBR-1706" columngutter="4px">
<divisions>
<division behavior="specified" verticalalign="top" width="50vw">
<components>
<buttonset model="Accounts" uniqueid="sk-1VFk-554" position="left">
<buttons>
<button type="multi" label="Get Ids" uniqueid="sk-1VGJ-939">
<actions>
<action type="updateRow" fieldmodel="UIOnly" affectedrows="context" field="FromActionIds" enclosevalueinquotes="true" value="{{#$Model.Accounts.data}}{{Id}},{{/$Model.Accounts.data}}"/>
</actions>
</button>
</buttons>
</buttonset>
<basicfieldeditor showheader="true" showsavecancel="false" showerrorsinline="true" model="UIOnly" uniqueid="sk-1VGE-903" mode="edit" layout="above">
<columns layoutmode="fixed">
<column uniqueid="sk-1VGE-899" width="100%">
<sections>
<section title="Section A" uniqueid="sk-1VGE-900">
<fields>
<field uniqueid="sk-1VGE-905" id="FromActionIds"/>
</fields>
</section>
<section title="Section B" uniqueid="sk-1VGE-902">
<fields>
<field uniqueid="sk-1VGE-904" id="CleanIds"/>
</fields>
</section>
</sections>
</column>
</columns>
</basicfieldeditor>
</components>
</division>
<division behavior="flex" verticalalign="top" minwidth="100px" ratio="1">
<components>
<skootable showconditions="true" showsavecancel="true" showerrorsinline="true" searchmethod="server" searchbox="true" showexportbuttons="false" hideheader="false" hidefooter="false" pagesize="10" alwaysresetpagination="false" createrecords="true" model="Accounts" buttonposition="" mode="read" allowcolumnreordering="true" responsive="true" uniqueid="sk-1R8C-408" heading="Accounts">
<fields>
<field id="Id" uniqueid="fi-1R8C-409"/>
<field id="Name" uniqueid="fi-1R8C-410"/>
</fields>
<rowactions>
<action type="edit"/>
<action type="delete"/>
</rowactions>
<massactions usefirstitemasdefault="true">
<action type="multi" label="Concat" icon="sk-icon-magic">
<actions>
<action type="custom" snippet="newSnippet"/>
<action type="adoptRows" sourcemodel="Accounts" targetmodel="Accounts_Adopt" affectedrows="context"/>
<action type="updateRow" fieldmodel="Accounts_Adopt" affectedrows="all" field="currval" enclosevalueinquotes="false" value="1"/>
</actions>
</action>
</massactions>
<views>
<view type="standard"/>
</views>
<actions defaultlabel="Global Actions" defaulticon="sk-icon-magic" usefirstitemasdefault="true"/>
</skootable>
</components>
</division>
</divisions>
<styles>
<styleitem type="background" bgtype="none"/>
</styles>
</grid>
</components>
<resources>
<labels/>
<javascript>
</javascript>
<css/>
<actionsequences uniqueid="sk-3N03-382">
<actionsequence id="d5becc77-bad2-4efa-beb5-7924c60b3c26" label="OppsQuery" type="reusable" uniqueid="sk-1R88-357">
<description/>
<actions>
<action type="blockUI"/>
<action type="requeryModel" model="Opps" behavior="loadmore"/>
<action type="unblockUI"/>
</actions>
</actionsequence>
<actionsequence id="5cd052c7-9b17-4ef0-b17c-fe3761ba4adc" label="New Sequence" type="reusable" uniqueid="sk-1R88-358">
<description/>
<actions/>
</actionsequence>
</actionsequences>
</resources>
<styles>
<styleitem type="background" bgtype="none"/>
</styles>
</skuidpage>
Thanks,
Bill
Matt,
Nice use of the action framework!
Thanks,
Bill
Hi Bill,
I used your code provided above to concatenate the Ids. It worked to concatenate all the account ids but now trying to generate a list of accounts from the ids.
It displays the if there is only one id but when trying to create a list from the concatenated list of ids it is throwing an error:
1. An error occurred while attempting to perform the following SOQL query: SELECT RecordTypeId,Name,Id FROM Account WHERE (Id in (‘001V000000av0p8IAA,001V000000aSsaBIA’)) Error:invalid ID field: 001V000000av0p8IAA,001V000000aSsaBIA
thanks, will try
Thanks Bill
As Jaiti said, we are trying to generate a list of accounts in a model based on the concatenated text string. Here is a picture of the error and the field.
Josef/Jaiti,
To use that string of Account Ids as the ‘in’ condition on a model, you will have to add single quotes around each of the commas. The string would have to look like this:
001V000000av0p8IAA’,'001V000000aSsaBIA
Then, when it goes into the ‘in’ condition, it will look like this:
SELECT RecordTypeId,Name,Id FROM Account WHERE (Id in (‘001V000000av0p8IAA’,‘001V000000aSsaBIA’))
If you have a model on your page with Account Ids in it (i.e. a list of Opportunities), why couldn’t you create a model on Account with a condition on Id where the value is ‘in’ the Opportunity model AccountId field?
Thanks,
Bill
Hey Bill,
That was my thought as well, however, Skuid is inserting a backslash long with the ’ symbol. See pic.
And to answer your question about storing Ids in a model. I am unable to do that because I am trying to create a relationship of many accounts to one campaign via a text field. Doing so will allow me to send a campaign link to a user and allow that user to view the accounts I’ve associated to said campaign.
Josef,
I ran into this before. You have to use JavaScript to set the condition. Here is what the code looks like:
var params = arguments[0],
$ = skuid.$;
var uiModel = skuid.$M('UIOnly');
var ids = uiModel.getFirstRow().CleanIds;
console.log(ids);
var loadModel = skuid.model.getModel('AccountsLoadFromString');
var condition = loadModel.getConditionByName('Id');
//assumes ids is a comma separated list of ids
var arrayids = ids.split(',');
console.log(arrayids);
loadModel.setCondition(condition, arrayids);
$.when(loadModel.load()).then(function(){
//do something after model loads
console.log('model loaded');
});
Here is a sample page that demonstrates this:
LEFT({{FromActionIds}},(LEN({{FromActionIds}}) - 1))
var params = arguments[0],
$ = skuid.$;
var uiModel = skuid.$M('UIOnly');
var ids = uiModel.getFirstRow().CleanIds;
console.log(ids);
var loadModel = skuid.model.getModel('AccountsLoadFromString');
var condition = loadModel.getConditionByName('Id');
//assumes ids is a comma separated list of ids
var arrayids = ids.split(',');
console.log(arrayids);
loadModel.setCondition(condition, arrayids);
$.when(loadModel.load()).then(function(){
//do something after model loads
console.log('model loaded');
});
```
Thanks,
Bill
It sounds like we’re trying to use the mass selection to set a model condition. If the goal is to filter a model based on a selected list, I would recommend just using a model condition based on a field in another model alongside adopting rows. Here’s an example
<skuidpage unsavedchangeswarning="yes" personalizationmode="server" showsidebar="true" useviewportmeta="true" showheader="true">
<models>
<model id="Accounts" limit="20" query="true" createrowifnonefound="false" datasource="salesforce" sobject="Account">
<fields>
<field id="Id"/>
<field id="Name"/>
<field id="Industry"/>
</fields>
<conditions/>
<actions/>
</model>
<model id="SelectedAccounts" limit="20" query="false" createrowifnonefound="false" datasource="salesforce" sobject="Account">
<fields>
<field id="Id"/>
<field id="Name"/>
<field id="Industry"/>
</fields>
<conditions/>
<actions/>
</model>
<model id="Opportunities" limit="20" query="false" createrowifnonefound="false" datasource="salesforce" sobject="Opportunity">
<fields>
<field id="Id"/>
<field id="AccountId"/>
<field id="Account.Name"/>
<field id="Name"/>
</fields>
<conditions>
<condition type="modelmerge" value="" field="AccountId" fieldtargetobjects="Account" operator="in" model="SelectedAccounts" enclosevalueinquotes="true" mergefield="Id" novaluebehavior="deactivate"/>
</conditions>
<actions/>
</model>
</models>
<components>
<grid uniqueid="sk-1w8S-438">
<divisions>
<division behavior="flex" minwidth="100px" ratio="1" verticalalign="top">
<components>
<skootable showconditions="true" showsavecancel="false" showerrorsinline="true" searchmethod="server" searchbox="true" showexportbuttons="false" hideheader="false" hidefooter="false" pagesize="10" alwaysresetpagination="false" createrecords="true" model="Accounts" buttonposition="" mode="read" allowcolumnreordering="true" responsive="true" uniqueid="sk-1w8Z-495" heading="Accounts">
<fields>
<field id="Id" uniqueid="fi-1w8Z-496"/>
<field id="Name" uniqueid="fi-1w8Z-497"/>
<field id="Industry" uniqueid="fi-1w8Z-498"/>
</fields>
<rowactions/>
<massactions usefirstitemasdefault="true">
<action type="multi" label="Find Opportunities for Selected Accounts" icon="sk-icon-magic">
<actions>
<action type="adoptRows" sourcemodel="Accounts" targetmodel="SelectedAccounts" affectedrows="context"/>
<action type="requeryModel" model="Opportunities" behavior="standard"/>
</actions>
</action>
</massactions>
<views>
<view type="standard"/>
</views>
</skootable>
</components>
</division>
<division behavior="flex" verticalalign="top" minwidth="100px" ratio="1">
<components>
<skootable showconditions="true" showsavecancel="false" showerrorsinline="true" searchmethod="server" searchbox="true" showexportbuttons="false" hideheader="false" hidefooter="false" pagesize="10" alwaysresetpagination="false" createrecords="true" model="SelectedAccounts" buttonposition="" mode="read" allowcolumnreordering="true" responsive="true" uniqueid="sk-1w8d-595" heading="Selected Accounts">
<fields>
<field id="Id" uniqueid="fi-1w8d-596"/>
<field id="Name" uniqueid="fi-1w8d-597"/>
<field id="Industry" uniqueid="fi-1w8d-598"/>
</fields>
<rowactions/>
<massactions usefirstitemasdefault="true"/>
<views>
<view type="standard"/>
</views>
</skootable>
</components>
</division>
</divisions>
<styles>
<styleitem type="background" bgtype="none"/>
</styles>
</grid>
<grid uniqueid="sk-1w8m-810">
<divisions>
<division behavior="flex" minwidth="100px" ratio="1">
<components>
<skootable showconditions="true" showsavecancel="false" showerrorsinline="true" searchmethod="server" searchbox="true" showexportbuttons="false" hideheader="false" hidefooter="false" pagesize="10" alwaysresetpagination="false" createrecords="true" model="Opportunities" buttonposition="" mode="read" allowcolumnreordering="true" responsive="true" uniqueid="sk-1w8g-692" heading="Opportunities in Selected Account">
<fields>
<field id="Id" uniqueid="fi-1w8g-693"/>
<field id="AccountId" uniqueid="fi-1w8g-694"/>
<field id="Account.Name" uniqueid="fi-1w8g-695"/>
<field id="Name" uniqueid="fi-1w8g-696"/>
</fields>
<rowactions/>
<massactions usefirstitemasdefault="true"/>
<views>
<view type="standard"/>
</views>
</skootable>
</components>
</division>
</divisions>
<styles>
<styleitem type="background" bgtype="none"/>
</styles>
</grid>
</components>
<resources>
<labels/>
<javascript/>
<css/>
<actionsequences uniqueid="sk-1w7z-232"/>
</resources>
<styles>
<styleitem type="background" bgtype="none"/>
</styles>
</skuidpage>
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.