Skip to main content

I have a table of accounts and for these accounts there is a row action that opens a popup to create a new activity record. In the popup there is a contact field which I would like to only filter in contacts who belong to the account that the popup was activated on. Currently when I open the popup and search for a contact to enter, the drop down pulls in all contacts in the database.


Another issue when attempting to set the filter is as follows:


Popup:


Field props


When going into Filters > Select Field:


Note it says Contact. I select the Account ID:


Account ID appears on the left but not on the right for ‘field’


When I change the “context” it reverts to eNo Field].


Is there a way I can set this to only pull up contacts that are on the account in context?


Thanks.

Michael,


Replace the WhoId field with a UI only reference field. Here is a sample page:


<skuidpage unsavedchangeswarning="" personalizationmode="server" useviewportmeta="true" showsidebar="true" showheader="true" tabtooverride="Account">
<models>
<model id="Account" limit="100" query="true" createrowifnonefound="false" datasource="salesforce" sobject="Account" type="">
<fields>
<field id="Name"/>
<field id="CreatedDate"/>
<field id="Id"/>
</fields>
<conditions/>
<actions/>
</model>
<model id="NewTask" limit="1" query="false" createrowifnonefound="false" datasource="salesforce" type="" sobject="Task">
<fields>
<field id="OwnerId"/>
<field id="Owner.Name"/>
<field id="WhoId"/>
<field id="Who.Name"/>
<field id="WhatId"/>
<field id="What.Name"/>
<field id="Subject"/>
<field id="ChooseName" uionly="true" displaytype="REFERENCE" label="Contact" ogdisplaytype="TEXT" datasource="salesforce" targetobjects="Contact" defaultvaluetype="fieldvalue" rel="SelectedContact" keyfield="Id">
<batchfields>
<batchfield field="Id"/>
<batchfield field="Name"/>
<batchfield field="AccountId" fieldtargetobjects="Account"/>
</batchfields>
</field>
</fields>
<conditions/>
<actions/>
</model>
<model id="ContactsForAccount" limit="20" query="false" createrowifnonefound="false" datasource="salesforce" type="" sobject="Contact">
<fields>
<field id="RecordTypeId"/>
<field id="AccountId"/>
<field id="Account.Name"/>
<field id="Name"/>
<field id="Id"/>
</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="Account" uniqueid="sk-2ZYncU-194">
<maintitle>
<template>{{Model.labelPlural}}</template>
</maintitle>
<subtitle>
<template>Home</template>
</subtitle>
<actions>
<action type="savecancel" uniqueid="sk-2ZYncT-192"/>
</actions>
</pagetitle>
<skootable showconditions="true" showsavecancel="false" searchmethod="server" searchbox="true" showexportbuttons="false" pagesize="10" createrecords="true" model="Account" mode="read" allowcolumnreordering="true" uniqueid="sk-2ZYnd1-208">
<fields>
<field id="Name" hideable="true" allowordering="true" uniqueid="fi-2ZYmpC-863" valuehalign="" type=""/>
<field id="CreatedDate" hideable="true" allowordering="true" uniqueid="fi-2ZYmpC-864"/>
</fields>
<rowactions>
<action type="multi" label="New Activity" icon="sk-icon-magic">
<actions>
<action type="setCondition" model="ContactsForAccount" condition="AccountId" value="{{Id}}"/>
<action type="requeryModel" model="ContactsForAccount" behavior="standard"/>
<action type="emptyModelData">
<models>
<model>NewTask</model>
</models>
</action>
<action type="createRow" model="NewTask" appendorprepend="prepend" defaultmodefornewitems="edit" affectedrows="context">
<defaults>
<default type="fieldvalue" field="WhatId" fieldtargetobjects="Account,Asset,AssetRelationship,Campaign,Case,ChannelProgram,ChannelProgramLevel,Contract,Ghost__c,Goal,LiveAgentSession,LiveChatTranscript,Metric,Opportunity,Order,PartnerFundAllocation,PartnerFundClaim,PartnerFundRequest,PartnerMarketingBudget,Product2,Quote,Solution,Store__c,WorkCoaching" enclosevalueinquotes="true" value="{{Id}}"/>
<default type="fieldvalue" field="What.Name" fieldtargetobjects="Account" enclosevalueinquotes="true" value="{{Name}}"/>
</defaults>
</action>
<action type="showPopup">
<popup title="New Popup" width="90%">
<components>
<pagetitle model="NewTask" uniqueid="sk-2ZZO2M-531">
<maintitle>New Task</maintitle>
<actions>
<action type="multi" label="Save" uniqueid="sk-2ZZRfK-563" icon="sk-icon-save">
<actions>
<action type="blockUI"/>
<action type="updateRow" fieldmodel="NewTask" affectedrows="context" field="WhoId" fieldtargetobjects="Contact,Lead" enclosevalueinquotes="true" value="{{ChooseName}}"/>
<action type="save">
<models>
<model>NewTask</model>
</models>
<onerroractions>
<action type="blockUI" message="There was an error" timeout="3000"/>
<action type="unblockUI" message="There was an error" timeout="3000"/>
</onerroractions>
</action>
<action type="closeTopmostPopup"/>
<action type="unblockUI"/>
</actions>
</action>
<action type="multi" label="Cancel" uniqueid="sk-2ZZRnS-569" icon="sk-icon-cancel">
<actions>
<action type="cancel">
<models>
<model>NewTask</model>
</models>
</action>
<action type="closeTopmostPopup"/>
</actions>
</action>
</actions>
</pagetitle>
<basicfieldeditor showheader="true" showsavecancel="false" showerrorsinline="true" model="NewTask" buttonposition="" uniqueid="sk-2ZZfZo-749" mode="edit">
<columns>
<column width="50%">
<sections>
<section title="Section A">
<fields>
<field uniqueid="sk-2ZZkcw-772" id="Subject" valuehalign="" type=""/>
<field uniqueid="sk-2ZeOkH-1847" id="ChooseName" valuehalign="" type="" optionsource="model" pagesize="5" redirecttype="datasourcedefault" optionmodel="ContactsForAccount">
<searchfields/>
<filters/>
</field>
</fields>
</section>
</sections>
</column>
<column width="50%">
<sections>
<section title="Section B" collapsible="no">
<fields>
<field uniqueid="sk-2ZZkcv-771" id="WhatId" valuehalign="" type=""/>
<field uniqueid="sk-2ZZkcw-773" id="OwnerId"/>
</fields>
</section>
</sections>
</column>
</columns>
</basicfieldeditor>
</components>
</popup>
</action>
</actions>
</action>
</rowactions>
<massactions usefirstitemasdefault="true">
<action type="massupdate"/>
<action type="massdelete"/>
</massactions>
<views>
<view type="standard"/>
</views>
</skootable>
</components>
<resources>
<labels/>
<css/>
<javascript/>
<actionsequences uniqueid="sk-2ZYwDR-323"/>
</resources>
<styles>
<styleitem type="background" bgtype="none"/>
</styles>
</skuidpage>

Thanks,


Bill


Hi Bill, I don’t actually need to use Who ID and am just using the contact field itself. .Contact__c], would I use the same method?


Michael,

This should work ‘as-is’…just updated your Contact__c field instead of WhoId.

You should also be able to adapt this directly to your Contact__c field.  Use the ContactsForAccounts model to limit the result set for your Contact__c field.

Thanks,

Bill


Hey Bill, Got it working! Thanks a bunch. 


Reply