Skip to main content

Hi everyone,


I have written a Java script(Snippet) for custom Popup that was working for earlier version perfectly.


But after brooklyn version it is giving below error:


1. There was a problem rendering a component of type pagetitle: Cannot read property ‘getFieldValue’ of undefined

2. There was a problem rendering a component of type basicfieldeditor: Cannot read property ‘getFieldValue’ of undefined


Here is my Java Script code:


var params = argumentsr0],

$ = skuid.$;

var models = skuid.model.map();

var pi = models.Matter;

var raw = pi.getFirstRow();

var SpecialS =raw.Special_Status__c;

var rowsToUpdate = {};


$.each(pi.getRows(),function(){

if(SpecialS ===‘Judgment’){

list = params.list,

model = params.model,

$xml = skuid.utils.makeXMLDoc,

HomepageTileModel = skuid.model.getModel(‘Matter’);

var contextModel;

$.each(HomepageTileModel.data, function(i, row){

contextModel = row;

console.log(‘contextModel’ + contextModel.Id);

});


    var popupXMLString = '<popup width="80%" title="Judgment">';

popupXMLString+=‘’;

popupXMLString+=‘’;

popupXMLString+=‘’;

popupXMLString+=‘{{Name}}’;

popupXMLString+=‘’;

popupXMLString+=‘’;

popupXMLString+=‘{{Model.label}}’;

popupXMLString+=‘ ’;

popupXMLString+=‘ ‘;

popupXMLString+=’’;

popupXMLString+=‘’;

popupXMLString+=‘’;

popupXMLString+=‘’;

popupXMLString+=‘Matter’;

popupXMLString+=‘’;

popupXMLString+=‘’;

popupXMLString+=‘’;

popupXMLString+=‘’;

popupXMLString+=‘’;

popupXMLString+=‘’;

popupXMLString+=‘’;

popupXMLString+=‘’;

popupXMLString+=‘’;

popupXMLString+=‘’;

popupXMLString+=‘’;

popupXMLString+=‘’;

popupXMLString+=‘’;

popupXMLString+=‘’;

popupXMLString+=‘’;

popupXMLString+=‘’;

popupXMLString+=‘’;

popupXMLString+=‘’;

popupXMLString+=‘’;

popupXMLString+=‘’;

popupXMLString+=‘’;

popupXMLString+=‘’;

popupXMLString+=‘’;

popupXMLString+=‘’;

popupXMLString+=‘’;

popupXMLString+=‘’;

popupXMLString+=‘’;

popupXMLString+=‘’;

popupXMLString+=‘’;

popupXMLString+=‘’;

popupXMLString+=‘’;

popupXMLString+=‘’;

popupXMLString+=‘’;

popupXMLString+=‘’;

popupXMLString+=‘’;

popupXMLString+=‘’;

popupXMLString+=‘’;

popupXMLString+=‘’;

popupXMLString+=‘’;

popupXMLString+=‘’;

popupXMLString+=‘ ‘;

popupXMLString+=’’;

popupXMLString+=‘’;

popupXMLString+=‘’;

popupXMLString+=‘’;

popupXMLString+=‘’;

popupXMLString+=‘’;

popupXMLString+=‘’;

popupXMLString+=‘’;


    var context = {
row: contextModel
};

var popupXML = skuid.utils.makeXMLDoc(popupXMLString);

var popup = skuid.utils.createPopupFromPopupXML(popupXML,context);


}

});

pi.updateRows(rowsToUpdate);



If you have any clue why it is happening, let me know as it is urgent.


thanks in advance

Gopal,


I think Skuid must be expecting a uniqueid for the page title and field editor. Here is the XML for a Page Title I added declaratively:


<pagetitle uniqueid="sk-3IhxBg-89">

You don’t have this in your popup XML.


Any reason you can’t move this popup to a declarative one? It will be a lot easier to maintain going forward.


Thanks,


Bill


Hi Bill,


Thanks for the reply.


Requirement: I have to show a popup for the specific value of picklist.


Thus I have written XML as per that.


I have tried to put the unique id in Page title and Field editor both.


But error remains


var popupXMLString = ‘’; popupXMLString+=‘’;
popupXMLString+=‘’;

popupXMLString+=‘’;

popupXMLString+=‘{{Name}}’;

popupXMLString+=‘’;

popupXMLString+=‘’;

popupXMLString+=‘{{Model.label}}’;

popupXMLString+=‘ ’;

popupXMLString+=‘ ‘;

popupXMLString+=’’;

popupXMLString+=‘’;

popupXMLString+=‘’;

popupXMLString+=‘’;

popupXMLString+=‘Matter’;

popupXMLString+=‘’;

popupXMLString+=‘’;

popupXMLString+=‘’;

popupXMLString+=‘’;

popupXMLString+=‘’;

popupXMLString+=‘’;

popupXMLString+=‘’;

popupXMLString+=‘’;

popupXMLString+=‘’;

popupXMLString+=‘’;

popupXMLString+=‘’;

popupXMLString+=‘’;

popupXMLString+=‘’;

popupXMLString+=‘’;

popupXMLString+=‘’;

popupXMLString+=‘’;

popupXMLString+=‘’;

popupXMLString+=‘’;

popupXMLString+=‘’;

popupXMLString+=‘’;
popupXMLString+=‘’;

popupXMLString+=‘’;

popupXMLString+=‘’;

popupXMLString+=‘’;

popupXMLString+=‘’;

popupXMLString+=‘’;

popupXMLString+=‘’;

popupXMLString+=‘’;

popupXMLString+=‘’;

popupXMLString+=‘’;

popupXMLString+=‘’;

popupXMLString+=‘’;

popupXMLString+=‘’;

popupXMLString+=‘’;

popupXMLString+=‘’;

popupXMLString+=‘’;

popupXMLString+=‘’;

popupXMLString+=‘’;

popupXMLString+=‘’;

popupXMLString+=‘’;

popupXMLString+=‘ ‘;

popupXMLString+=’’;

popupXMLString+=‘’;

popupXMLString+=‘’;

popupXMLString+=‘’;

popupXMLString+=‘’;

popupXMLString+=‘’;

popupXMLString+=‘’;

popupXMLString+=‘’;


Please suggest.


Gopal,


I would try to ‘console.log’ the popupXMLString and make sure that the format is good.


Then I would try to isolate where the error is occurring. Try commenting the code that generates the popup first and see if that clears the error. Then begin adding back pieces of the popup in stages. Just the tag first, then add others.


If it breaks before the popup code, then you’ll want to verify that you have data when you get the model, rows, params; etc.


Thanks,


Bill


Hi Bill,

I have tried with that way also.

But issue persists as it is.

Please help.

Thanks in advance


Gopal,


Take a look at this Task Detail page. It uses the Branch action on a change of the Task model. When you change the Call Type to “Internal”, it opens the popup. This is all done declaratively (no snippet).


If you still want to go down the custom route, take a look at where the unique id’s show in all of the components. I think you will need to add them on the actions as well as the fields.



<skuidpage showheader="true" personalizationmode="server" theme="TestCloneLightning" showsidebar="true" unsavedchangeswarning="yes" tabtooverride="Task" useviewportmeta="true">
<models>
<model type="" id="Task" datasource="salesforce" sobject="Task" createrowifnonefound="false" query="true" limit="1">
<fields>
<field id="Subject"/>
<field id="CreatedDate"/>
<field label="Select Contact" id="SelectContact" datasource="salesforce" targetobjects="Contact" keyfield="Id" rel="Contact" ogdisplaytype="TEXT" displaytype="REFERENCE" uionly="true">
<batchfields>
<batchfield field="Name"/>
</batchfields>
</field>
<field id="AccountId"/>
<field id="Account.Name"/>
<field id="IsReminderSet"/>
<field id="Description"/>
<field id="CallType"/>
</fields>
<conditions>
<condition type="param" value="id" enclosevalueinquotes="true" field="Id" operator="=" novaluebehavior="noquery"/>
</conditions>
<actions>
<action>
<actions>
<action type="branch" model="Task" label="CallType = Internal">
<formula>{{CallType}}=='Internal'</formula>
<iftrueactions>
<action type="showPopup">
<popup title="New Popup" width="90%">
<components>
<pagetitle model="Task" uniqueid="sk-vq9m-220">
<maintitle>
<template>{{Subject}}</template>
</maintitle>
<subtitle>
<template>{{Model.label}}</template>
</subtitle>
<actions>
<action type="multi" label="Save" uniqueid="sk-vqR8-223" icon="sk-icon-save">
<actions>
<action type="save">
<models>
<model>Task</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"/>
</actions>
</action>
</actions>
</pagetitle>
<basicfieldeditor showheader="true" showsavecancel="false" showerrorsinline="true" model="Task" buttonposition="" uniqueid="sk-vvX_-235" mode="edit">
<columns>
<column width="50%">
<sections>
<section title="Section A" collapsible="no">
<fields>
<field uniqueid="sk-vxfB-249" id="Subject"/>
</fields>
</section>
</sections>
</column>
<column width="50%">
<sections>
<section title="Section B" collapsible="no">
<fields>
<field uniqueid="sk-vz6n-254" id="Description"/>
</fields>
</section>
</sections>
</column>
</columns>
</basicfieldeditor>
</components>
</popup>
</action>
</iftrueactions>
</action>
</actions>
<events>
<event>row.updated</event>
</events>
<fields>
<field>CallType</field>
</fields>
</action>
</actions>
</model>
</models>
<components>
<pagetitle model="Task" uniqueid="sk-33agP--89">
<maintitle>
<template>{{Subject}}</template>
</maintitle>
<subtitle>
<template>{{Model.label}}</template>
</subtitle>
<actions>
<action type="delete" uniqueid="sk-33agPp-82"/>
<action type="clone" uniqueid="sk-33agPt-84"/>
<action type="share" uniqueid="sk-33agPx-86"/>
<action type="savecancel" uniqueid="sk-33agP_-88" window="self"/>
</actions>
</pagetitle>
<basicfieldeditor model="Task" uniqueid="sk-33agQZ-100" mode="read" showheader="true" showsavecancel="false" buttonposition="" layout="">
<columns layoutmode="responsive" columngutter="4px" rowgutter="4px">
<column ratio="1" minwidth="300px" behavior="flex">
<sections>
<section title="Basics">
<fields>
<field uniqueid="sk-qrac-129" id="CallType" valuehalign="" type=""/>
<field type="" id="SelectContact" uniqueid="sk-3gry2i-141" valuehalign=""/>
<field id="AccountId" uniqueid="sk-3gsFzR-120"/>
<field id="Subject" uniqueid="sk-33agQC-95"/>
</fields>
</section>
</sections>
</column>
<column ratio="1" minwidth="300px" behavior="flex">
<sections>
<section title="System Info" collapsible="no">
<fields>
<field id="CreatedDate" uniqueid="sk-33agQI-99"/>
<field uniqueid="sk-2uv7bQ-142" id="IsReminderSet"/>
</fields>
</section>
</sections>
</column>
</columns>
</basicfieldeditor>
</components>
<resources>
<labels/>
<css/>
<javascript/>
</resources>
<styles>
<styleitem type="background" bgtype="none"/>
</styles>
</skuidpage>

Thanks,


Bill


Hi Bill,

Following trick works for me:
1. Add a model action onto the model that the field editor is looking at
2. In the model action, have the initiating event be row in model is updated, and specifically the picklist field 
3. In the model action, the first action is a branch where the formula is {{PicklistFieldName}} == “ValueThatTriggersPopup”
4. Under the branch-if-true actions (hit the red plus next to Branch), you can include the popup

Thanks