I want to display child records of a particular object whose parentid are in this text field.How can

edited June 25, 2020 in Questions
I have text field with series of IDs separated by comma. I want to display child records of a particular object whose parentids are in this text field.How can I do it in skuid?

Comments

  • Pat VachonPat Vachon ๐Ÿ’Ž๐Ÿ’Ž๐Ÿ’Ž
    edited June 25, 2020
    You'll have to use a snippet or maybe "hack" the xml.
  • edited June 25, 2020
    Hi pat, How to use snippet and where can we write this snippet?
  • Pat VachonPat Vachon ๐Ÿ’Ž๐Ÿ’Ž๐Ÿ’Ž
    edited October 9, 2019
    I would use https://docs.skuid.com/latest/en/ and then add the snippet to the page.
  • edited October 14, 2019
    Here's a potential solution expanding on Pat's response:
    - Parse that text field and populate a ui-only model with the list of ids from that fieldย 
    - Point your "Field from another model" model condition to that ui-only model to get the child records. Don't forget to use "in", not "equals to", since you want to return the match for all records in the ui-modelย 

    Here's XML showing how to use a snippet to convert a text field to records in an ui-only model:
    <skuidpage unsavedchangeswarning="yes" personalizationmode="server" showsidebar="true" showheader="true">
    <models>
    <model id="SourceModel" limit="20" query="true" createrowifnonefound="true" datasource="Ui-Only" processonclient="true">
    <fields>
    <field id="list_of_things" displaytype="TEXT" length="255" label="List of Things" defaultvaluetype="fieldvalue" defaultValue="pumpkin,cinnamon,cider,nutmeg,vanilla,apple,chai"/>
    </fields>
    <conditions/>
    <actions/>
    </model>
    <model id="UiModel" limit="20" query="true" createrowifnonefound="false" datasource="Ui-Only" processonclient="true">
    <fields>
    <field id="name" displaytype="TEXT" length="255" label="Name"/>
    </fields>
    <conditions/>
    <actions/>
    </model>
    </models>
    <components>
    <basicfieldeditor showheader="true" showsavecancel="false" showerrorsinline="true" model="SourceModel" uniqueid="sk-2o1G-1548" mode="read">
    <columns>
    <column width="100%" uniqueid="sk-2o1G-1544">
    <sections>
    <section title="Section A" uniqueid="sk-2o1G-1545" collapsible="no">
    <fields>
    <field uniqueid="sk-2o32-1882" id="list_of_things"/>
    </fields>
    </section>
    </sections>
    </column>
    </columns>
    </basicfieldeditor>
    <wrapper uniqueid="sk-2o3P-2001">
    <components>
    <buttonset model="SourceModel" uniqueid="sk-2o3B-1906" position="center">
    <buttons>
    <button type="multi" label="Parse Text Field to Ui Model below" uniqueid="sk-2o3C-1911">
    <actions>
    <action type="custom" snippet="parseTextFieldToUiModel"/>
    </actions>
    </button>
    </buttons>
    <renderconditions logictype="and"/>
    </buttonset>
    </components>
    <styles>
    <styleitem type="background"/>
    <styleitem type="border" padding="bottom,top,">
    <styles>
    <styleitem property="padding-top" value="24px"/>
    <styleitem property="padding-bottom" value="24px"/>
    <styleitem property="box-sizing" value="border-box"/>
    </styles>
    </styleitem>
    <styleitem type="size"/>
    </styles>
    </wrapper>
    <skootable showconditions="true" showsavecancel="false" showerrorsinline="true" searchmethod="client" searchbox="true" showexportbuttons="false" hideheader="false" hidefooter="false" pagesize="10" alwaysresetpagination="false" createrecords="true" model="UiModel" buttonposition="" mode="edit" allowcolumnreordering="true" responsive="true" uniqueid="sk-2o0i-1376">
    <fields>
    <field id="name" uniqueid="fi-2o0i-1377"/>
    </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="parseTextFieldToUiModel" cachelocation="false" url="">var $ = skuid.$;
    var list_of_things = skuid.model.getModel('SourceModel').getFirstRow().list_of_things.split(',');
    var UiModel = skuid.model.getModel('UiModel');
    list_of_things.forEach(function(thing) {
    ย  ย  UiModel.createRow({
    additionalConditions: [
    { field: 'name', value: thing}
    ], doAppend: true
    });
    });</jsitem>
    </javascript>
    <css/>
    <actionsequences uniqueid="sk-2n_z-599"/>
    </resources>
    <styles>
    <styleitem type="background" bgtype="none"/>
    </styles>
    </skuidpage>
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!