Set value for field from another model when adding a row

edited March 10, 2020 in Questions
So I am trying to set the value of a new row field via the save button.   The value should be the Sales_Rep__r.Id from the object Opp,   Saved to 
Sales_Rep_1__c on the OppItem object.   

From the documentation I though I just needed to call the value via {{$}} or Opp.Sales_rep_r.Id  But when ever I try like below, nothing is passed to the new field.   

Any ideas?

<skuidpage unsavedchangeswarning="yes" personalizationmode="server" showsidebar="true" useviewportmeta="true" showheader="true">
        <model id="Opp" limit="1" query="true" createrowifnonefound="false" datasource="salesforce" sobject="Opportunity">
                <field id="Sales_Rep__c"/>
                <field id="Sales_Rep__r.Name"/>
                <field id="Sales_Rep__r.Id"/>
                <condition type="param" value="id" field="Id" operator="=" enclosevalueinquotes="true" novaluebehavior="noquery"/>
        <model id="OppItem" query="false" createrowifnonefound="false" datasource="salesforce" sobject="OpportunityLineItem">
                <field id="Sales_Rep_1__c"/>
                <field id="Sales_Rep_1__r.Name"/>
                <field id="Sales_Rep_1__r.Id"/>
                <field id="Product2Id"/>
                <field id="Product2.Name"/>
                <field id="OpportunityId"/>
                <field id="Opportunity.Name"/>
                <field id="Quantity"/>
                <field id="UnitPrice"/>
                <condition type="param" value="id" field="Id" operator="=" enclosevalueinquotes="true" novaluebehavior="noquery"/>
        <buttonset model="Opp" uniqueid="sk-Lk3-464">
                <button type="multi" label="save" uniqueid="sk-Lk3-469">
                        <action type="createRow" model="OppItem" appendorprepend="prepend" defaultmodefornewitems="edit" affectedrows="context">
                                <default type="fieldvalue" field="Sales_Rep_1__c" fieldtargetobjects="Sales_Rep__c" enclosevalueinquotes="true" value="{{$}}"/>
                                <default type="fieldvalue" field="OpportunityId" fieldtargetobjects="Opportunity" enclosevalueinquotes="true" value="{{$}}"/>
                                <default type="fieldvalue" field="Quantity" fieldtargetobjects="OpportunityLineItem" enclosevalueinquotes="false" value="2"/>
                                <default type="fieldvalue" field="UnitPrice" fieldtargetobjects="OpportunityLineItem" enclosevalueinquotes="false" value="1"/>
                                <default type="fieldvalue" field="Product2Id" fieldtargetobjects="Product2" enclosevalueinquotes="true" value="01tf4000001AsVfAAK"/>
                        <action type="save">
                        <action type="redirect" window="self" url="/{Id}"/>
        <richtext multiple="false" uniqueid="sk-LlP-666" model="OppItem">
            <contents>&lt;p&gt;{{Sales_Rep__r.Id}} should&amp;nbsp; {{$}}&lt;/p&gt;
        <actionsequences uniqueid="sk-LjW-353"/>
        <styleitem type="background" bgtype="none"/>


  • edited September 3, 2019
    It seems we have been unable to do this reliably also. The approach I've been shown is to set Conditions on the OppItem model, for Sales_Rep_1__c and for OpportunityId. Set the value as "Field from another model" and reference Opp. (You could also make those conditions filterable and use the "Activate & Set value of Model Condition" action if you needed to do so conditionally.)
  • edited March 10, 2020
    Hmmm Could you post an example,   I am trying that but not getting any results that way.
  • edited September 3, 2019
    Looking for an example, the first instance I checked actually uses the method you proposed here. I wondered if there were any difference, I looked at your page again and saw: {{$}}. But the field name is Sales_Rep__c. See if case isn't the case!
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!