Skip to main content

Hi All,


My setup for this looks like so: There is a field on the Account record that is a reference to a custom meeting object. This field is blank by default. I have created a button that creates a new meeting record and fills in some of the fields saves, then sets the this new record id in the blank field on the account.


The button logic is intended to go like so:


if AccountField == null: create Meeting field update on account open popup else: open popup

The popup should reference the newly populated field on the account and display the contents of this new record.


So far with my testing the button is successful in creating a new record and putting in in place, and if there is already a record in place is successfully opens the popup and displays the record correctly.


The problem I am now running into is in the first portion of the logic. The record is created and placed in the empty account field BUT the popup fails to open up this newly placed record reference.


What is happening is the new record is created, field is updated, then the popup opens and yields the following:


Strange because if I refresh and hit the button it opens but I cannot get it to work within the initial button press.


If anyone has any ideas on how to achieve this please let me know!

Is there any reason you’re not attempting to do this declaratively? What is your reason for feeling the need to code this?


Michael,

As Steven said, I would recommend doing this declaratively.

Do you have a model action on your ‘account’ model that runs when the ‘meeting lookup’ field is populated?  I’d guess that your action is doing a query to get your meeting record data.  Since you populated the lookup with Skuid generated id (and not a ‘real’ meeting Id), I think that your model de-activates the Id condition and attempts to load to whatever limit you have on your model (presumably no limit).

Try moving the action to update the ‘account’ model to the save button on your new meeting popup.  This way you will get a ‘real’ Id set on the ‘account’ record.  Make sure you save your new meeting, then update the ‘account’ model.

Thanks,

Bill


I guess I forgot to mention I am using brach logic within the action framework


Michael,


My apologies for not paying attention to the title of your issue. You did say that the popup was done using an action sequence.


I am not sure that this is setup exactly as you have in your page. I attempted the same logic using a Contact record. My button creates a new Account instead. Please try this in your org. Maybe something will jump out at you.


Thanks,


Bill


<skuidpage unsavedchangeswarning="yes" personalizationmode="server" useviewportmeta="true" showsidebar="true" showheader="true" tabtooverride="Contact">
<models>
<model id="Contact" limit="1" query="true" createrowifnonefound="false" datasourcetype="salesforce" datasource="salesforce" sobject="Contact">
<fields>
<field id="FirstName"/>
<field id="LastName"/>
<field id="CreatedDate"/>
<field id="AccountId"/>
<field id="Account.Name"/>
</fields>
<conditions>
<condition type="param" enclosevalueinquotes="true" operator="=" field="Id" value="id"/>
</conditions>
<actions/>
</model>
<model id="NewAccount" limit="1" query="false" createrowifnonefound="false" datasource="salesforce" sobject="Account">
<fields>
<field id="RecordTypeId"/>
<field id="Name"/>
<field id="Id"/>
</fields>
<conditions>
<condition type="fieldvalue" value="" enclosevalueinquotes="true" field="Id" state="filterableoff" inactive="true" name="Id"/>
</conditions>
<actions/>
</model>
</models>
<components>
<pagetitle model="Contact" uniqueid="sk-3XGD-208">
<maintitle>
<template>{{FirstName}} {{LastName}}</template>
</maintitle>
<subtitle>
<template>{{Model.label}}</template>
</subtitle>
<actions>
<action type="multi" label="New Account" uniqueid="sk-3XGD-318">
<actions>
<action type="branch" whenfinished="stop" model="Contact">
<formula>{{AccountId}}==null</formula>
<iftrueactions>
<action type="emptyModelData">
<models>
<model>NewAccount</model>
</models>
</action>
<action type="createRow" model="NewAccount" appendorprepend="prepend" defaultmodefornewitems="edit" affectedrows="context"/>
<action type="showPopup">
<popup title="New Account" width="50%">
<components>
<pagetitle model="NewAccount" uniqueid="sk-3XGD-502">
<maintitle>
<template>{{Name}}</template>
</maintitle>
<subtitle>
<template>{{Model.label}}</template>
</subtitle>
<actions>
<action type="multi" label="Save" uniqueid="sk-3XGD-529" icon="sk-icon-save">
<actions>
<action type="save" rollbackonanyerror="true">
<models>
<model>NewAccount</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="updateRow" fieldmodel="Contact" affectedrows="context" field="AccountId" fieldtargetobjects="Account" enclosevalueinquotes="true" value="{{$Model.NewAccount.data.0.Id}}"/>
<action type="closeTopmostPopup"/>
</actions>
</action>
<action type="multi" label="Cancel" uniqueid="sk-3XGD-533" icon="sk-icon-cancel">
<actions>
<action type="cancel">
<models>
<model>NewAccount</model>
</models>
</action>
<action type="closeTopmostPopup"/>
</actions>
</action>
</actions>
</pagetitle>
<basicfieldeditor showheader="true" showsavecancel="false" showerrorsinline="true" model="NewAccount" uniqueid="sk-3XGD-749" mode="edit">
<columns>
<column width="100%">
<sections>
<section title="Details" collapsible="no">
<fields>
<field uniqueid="sk-3XGD-777" id="Name"/>
</fields>
</section>
</sections>
</column>
</columns>
</basicfieldeditor>
</components>
</popup>
</action>
</iftrueactions>
</action>
<action type="setCondition" model="NewAccount" behavior="standard" condition="Id" value="{{AccountId}}"/>
<action type="requeryModel" model="NewAccount" behavior="standard"/>
<action type="showPopup">
<popup title="Show Account" width="50%">
<components>
<basicfieldeditor showheader="true" showsavecancel="false" showerrorsinline="true" model="NewAccount" uniqueid="sk-3XGD-901" mode="read">
<columns>
<column width="100%">
<sections>
<section title="Details" collapsible="no">
<fields>
<field uniqueid="sk-3XGD-946" id="Name"/>
</fields>
</section>
</sections>
</column>
</columns>
</basicfieldeditor>
</components>
</popup>
</action>
</actions>
</action>
<action type="savecancel" window="self" uniqueid="sk-3XGD-206"/>
</actions>
</pagetitle>
<basicfieldeditor showsavecancel="false" showheader="true" model="Contact" mode="read" uniqueid="sk-3XGD-227">
<columns>
<column width="50%">
<sections>
<section title="Basics" collapsible="no">
<fields>
<field id="FirstName" uniqueid="sk-3XGD-216"/>
<field id="LastName" uniqueid="sk-3XGD-219"/>
</fields>
</section>
</sections>
</column>
<column width="50%">
<sections>
<section title="System Info">
<fields>
<field uniqueid="sk-3XGD-262" id="AccountId"/>
</fields>
</section>
</sections>
</column>
</columns>
</basicfieldeditor>
</components>
<resources>
<labels/>
<css/>
<javascript/>
<actionsequences uniqueid="sk-3XGD-258"/>
</resources>
<styles>
<styleitem type="background" bgtype="none"/>
</styles>
</skuidpage>

Thanks a bunch Bill! I will try it out.


Reply