How to Pre-populate Parent look up name when i update child Lookup field value

  • 1
  • Problem
  • Updated 1 year ago
  • Solved
On Application Object i have two lookup fields.

1.Account
2.Product

Product having look up on account model

when i updating account field value, Product name should be pre-populate.but i am getting product id when i update Account Field.please refer the below screenshot.
 .

when account Row model updating i am calling action there i am updating product query string.
{{$Model.product.data.0.Id}}

from above screenshot, i want to display product name instead of product Id. Please help on this
Photo of raj

raj

  • 840 Points 500 badge 2x thumb

Posted 1 year ago

  • 1
Photo of Bill McCullough

Bill McCullough, Champion

  • 12,436 Points 10k badge 2x thumb
raj,

Update your product query to also retrieve the 'Name' field from the product ({{$Model.product.data.0.Name}}.  In your model action, include a second update row action to update the 'name' field of the CL Product field.

Thanks,

Bill
Photo of raj

raj

  • 840 Points 500 badge 2x thumb
when i select product lookup directly i am able to see my product name.
but when i am doing from action it showing id.

here my requirement is when i select account account i want show product name(Test Product) instead of Id like from first image.

TestProduct Api field is 'clcommon__Product_Name__c'
Photo of Bill McCullough

Bill McCullough, Champion

  • 12,436 Points 10k badge 2x thumb
raj,

If I understand you, the CL Product field in your screenshot has the API name of 'clcommon__Product_Name__c'.  You are updating this field with the Id from your query.

I want you to update 'clcommon__Product_Name__r.Name' with the Name of the product from your query.

Thanks,

Bill
Photo of raj

raj

  • 840 Points 500 badge 2x thumb
CL Product(genesis__CL_Product__c) is a lookup  field, from here i have to select the product name.Product name Api is 'clcommon__Product_Name__c'
Photo of Bill McCullough

Bill McCullough, Champion

  • 12,436 Points 10k badge 2x thumb
raj,

Here is a page that demonstrates what I am trying to tell you.  This page creates a new Task.  You select an Account first.  Then click on the button 'Select Child Contact'.  This loads a model with a list of the contacts whose parent is the select account.  Click the row action next to the contact's name to 'select them' for the WhoId field on the Task.  This is what you are trying to do with the CL Product field on your page.

Take a look at the row action on the table in the pop up.
<actions>
  <action type="updateRow" sourcemodel="Task" targetmodel="Task" affectedrows="context" fieldmodel="Task" field="WhoId" fieldtargetobjects="Contact,Lead" enclosevalueinquotes="true" value="{{Id}}"/>
  <action type="updateRow" fieldmodel="Task" affectedrows="context" field="Who.Name" enclosevalueinquotes="true" value="{{Name}}"/>
  <action type="closeTopmostPopup"/>
</actions>
Thanks,

Bill


<skuidpage unsavedchangeswarning="yes" personalizationmode="server" showsidebar="true" useviewportmeta="true" showheader="true">
    <models>
        <model id="Task" limit="1" query="false" createrowifnonefound="true" datasource="salesforce" type="" sobject="Task">
            <fields>
                <field id="AccountId"/>
                <field id="Account.Name"/>
                <field id="WhoId"/>
                <field id="Who.Name"/>
                <field id="Subject"/>
                <field id="WhatId"/>
                <field id="What.Name"/>
            </fields>
            <conditions/>
            <actions/>
        </model>
        <model id="LookupContacts" limit="200" query="false" createrowifnonefound="false" datasource="salesforce" type="" sobject="Contact">
            <fields>
                <field id="Id"/>
                <field id="Name"/>
            </fields>
            <conditions>
                <condition type="fieldvalue" value="" enclosevalueinquotes="true" field="AccountId" fieldtargetobjects="Account" state="filterableoff" inactive="true" name="AccountId"/>
            </conditions>
            <actions/>
        </model>
    </models>
    <components>
        <pagetitle model="Task" uniqueid="sk-3xF69b-152">
            <maintitle>
                <template>{{Subject}}</template>
            </maintitle>
            <subtitle>
                <template>{{Model.label}}</template>
            </subtitle>
            <actions>
                <action type="multi" label="Select Child Contact" uniqueid="sk-3xF8E--164" icon="sk-icon-search">
                    <renderconditions logictype="and"/>
                    <enableconditions logictype="and">
                        <condition type="blank" operator="!=" fieldmodel="Task" sourcetype="fieldvalue" field="WhatId" fieldtargetobjects="Account,Asset,Campaign,Case,Contract,Ghost__c,Goal,LiveAgentSession,LiveChatTranscript,Metric,Opportunity,Order,Product2,Quote,Solution,Store__c,WorkCoaching" value="null" enclosevalueinquotes="false"/>
                    </enableconditions>
                    <actions>
                        <action type="setCondition" sourcemodel="Task" targetmodel="Task" affectedrows="context" model="LookupContacts" condition="AccountId" value="{{WhatId}}"/>
                        <action type="requeryModel" model="LookupContacts" behavior="standard"/>
                        <action type="showPopup">
                            <popup title="Select Contact" width="40%">
                                <components>
                                    <skootable showconditions="true" showsavecancel="false" showerrorsinline="true" searchmethod="server" searchbox="true" showexportbuttons="false" pagesize="10" alwaysresetpagination="false" createrecords="false" model="LookupContacts" buttonposition="" mode="readonly" allowcolumnreordering="false" responsive="true" uniqueid="sk-3xG7UL-345">
                                        <fields>
                                            <field id="Name" hideable="true" uniqueid="fi-3xG97p-360"/>
                                        </fields>
                                        <rowactions>
                                            <action type="multi" label="Select Contact" icon="sk-icon-magic">
                                                <actions>
                                                    <action type="updateRow" sourcemodel="Task" targetmodel="Task" affectedrows="context" fieldmodel="Task" field="WhoId" fieldtargetobjects="Contact,Lead" enclosevalueinquotes="true" value="{{Id}}"/>
                                                    <action type="updateRow" fieldmodel="Task" affectedrows="context" field="Who.Name" enclosevalueinquotes="true" value="{{Name}}"/>
                                                    <action type="closeTopmostPopup"/>
                                                </actions>
                                            </action>
                                        </rowactions>
                                        <massactions usefirstitemasdefault="true"/>
                                        <views>
                                            <view type="standard"/>
                                        </views>
                                    </skootable>
                                </components>
                            </popup>
                        </action>
                    </actions>
                </action>
                <action type="savecancel" label="New Button" uniqueid="sk-3xF6ay-157"/>
            </actions>
        </pagetitle>
        <basicfieldeditor showheader="true" showsavecancel="false" showerrorsinline="true" model="Task" buttonposition="" uniqueid="sk-3xF2Dp-130" mode="edit">
            <columns>
                <column width="100%">
                    <sections>
                        <section title="Details" collapsible="no">
                            <fields>
                                <field uniqueid="sk-3xFX-z-232" id="WhatId" valuehalign="" type="">
                                    <label>Select Account</label>
                                </field>
                                <field uniqueid="sk-3xFHXQ-187" id="WhoId" valuehalign="" type="">
                                    <renderconditions logictype="and" onhidedatabehavior="keep"/>
                                    <enableconditions logictype="and">
                                        <condition type="blank" operator="!=" fieldmodel="Task" sourcetype="fieldvalue" field="WhatId" fieldtargetobjects="Account,Asset,Campaign,Case,Contract,Ghost__c,Goal,LiveAgentSession,LiveChatTranscript,Metric,Opportunity,Order,Product2,Quote,Solution,Store__c,WorkCoaching" value="null" enclosevalueinquotes="false"/>
                                    </enableconditions>
                                    <label>Selected Contact</label>
                                </field>
                                <field uniqueid="sk-3xFHXP-186" id="Subject" valuehalign="" type=""/>
                            </fields>
                        </section>
                    </sections>
                </column>
            </columns>
        </basicfieldeditor>
    </components>
    <resources>
        <labels/>
        <javascript/>
        <css/>
    </resources>
    <styles>
        <styleitem type="background" bgtype="none"/>
    </styles>
</skuidpage>
Photo of raj

raj

  • 840 Points 500 badge 2x thumb
on Application object i have a lookup field Cl Product(genesis__CL_product__c). from this i am taking CL product model field  Api name  clcommon__CL_Prouct__r.clcommon__Product_Name__c.

when i select product i want to display name instead of ID.