<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://sugarclub.sugarcrm.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Changes in Sidecar model not reflected in Sugar bean</title><link>https://sugarclub.sugarcrm.com/dev-club/f/questions-answers/2049/changes-in-sidecar-model-not-reflected-in-sugar-bean</link><description>I have a requirement where a field called resource_rate_actual has be set equal to one of several fields, depending on the value selected in a dropdown. I&amp;#39;ve set it up in record.js view controller like this: initialize: function (options) { this._super</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: Changes in Sidecar model not reflected in Sugar bean</title><link>https://sugarclub.sugarcrm.com/thread/7496?ContentTypeID=1</link><pubDate>Mon, 16 Mar 2020 14:52:57 GMT</pubDate><guid isPermaLink="false">5c521d64-519d-47a6-9065-134618b211bf:771211da-024a-409c-9f64-b9cd1b95c0f7</guid><dc:creator>Yury Voloshin</dc:creator><description>&lt;p&gt;Thank you Maryam! Breaking up &lt;em&gt;this.model.set&lt;/em&gt; and &lt;em&gt;this.model.get&lt;/em&gt; into two statements instead of one actually worked and now the record is saved with the logic hook deactivated. This is strange because having them as one statement works well in other view controllers. But in any case, now I&amp;#39;m able to remove the logic hook.&amp;nbsp;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Changes in Sidecar model not reflected in Sugar bean</title><link>https://sugarclub.sugarcrm.com/thread/7498?ContentTypeID=1</link><pubDate>Wed, 11 Mar 2020 01:26:12 GMT</pubDate><guid isPermaLink="false">5c521d64-519d-47a6-9065-134618b211bf:d67ef3fa-921f-43ef-ad86-99f82ca5f9df</guid><dc:creator>Francesca Shiekh</dc:creator><description>&lt;p&gt;You don&amp;#39;t need both, you can do it in the controller OR in the logic hook.&lt;/p&gt;&lt;p&gt;In your case I would choose the logic hook but it is a personal choice, I think it is cleaner and less dependent on the interface, but I&amp;#39;m old-school-PHP. &lt;span class="emoticon_happy emoticon-inline" style="height:16px;width:16px;"&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;I think the issue with the controller is that the&amp;nbsp;interface tracks what has changed and then saves only those fields, because your field in not in the view it is not seen as changed.&lt;br /&gt;Try seeing if the changed&amp;nbsp;fields include it by printing the changed objects keys in your console:&lt;/p&gt;&lt;pre class="language-javascript line-numbers"&gt;&lt;code&gt;changed &lt;span class="operator token"&gt;=&lt;/span&gt; Object&lt;span class="punctuation token"&gt;.&lt;/span&gt;&lt;span class="token function"&gt;keys&lt;/span&gt;&lt;span class="punctuation token"&gt;(&lt;/span&gt;self&lt;span class="punctuation token"&gt;.&lt;/span&gt;model&lt;span class="punctuation token"&gt;.&lt;/span&gt;&lt;span class="token function"&gt;changedAttributes&lt;/span&gt;&lt;span class="punctuation token"&gt;(&lt;/span&gt;self&lt;span class="punctuation token"&gt;.&lt;/span&gt;model&lt;span class="punctuation token"&gt;.&lt;/span&gt;&lt;span class="token function"&gt;getSynced&lt;/span&gt;&lt;span class="punctuation token"&gt;(&lt;/span&gt;&lt;span class="punctuation token"&gt;)&lt;/span&gt;&lt;span class="punctuation token"&gt;)&lt;/span&gt;&lt;span class="punctuation token"&gt;)&lt;/span&gt;&lt;span class="punctuation token"&gt;;&lt;/span&gt;&lt;br /&gt;console&lt;span class="punctuation token"&gt;.&lt;/span&gt;&lt;span class="token function"&gt;log&lt;/span&gt;&lt;span class="punctuation token"&gt;(&lt;/span&gt;changed&lt;span class="punctuation token"&gt;)&lt;/span&gt;&lt;span class="punctuation token"&gt;;&lt;/span&gt;&lt;span class="line-numbers-rows"&gt;&lt;span&gt;&lt;/span&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;You could dig deep into the sidecar bean sidecar/src/data/bean.js and see if you can somehow push that field into the changed attributes... but I think you would be digging VERY deep and for little gain (again, I&amp;#39;m old-school-PHP).&lt;/p&gt;&lt;p&gt;If you still want to do it from the controller I suggest you try one more thing: do it in silent mode, that way - I think - it should update regardless of whether it is in the interface or not (though you would need to test my theory). BUT it will update BEFORE the user clicks Save and regardless of whether they save or not, so again, I think the logic hook is your best route...&lt;/p&gt;&lt;p&gt;&lt;br /&gt;To update in silent mode your code would look like:&lt;/p&gt;&lt;pre class="language-javascript line-numbers"&gt;&lt;code&gt;&lt;span class="keyword token"&gt;this&lt;/span&gt;&lt;span class="punctuation token"&gt;.&lt;/span&gt;model&lt;span class="punctuation token"&gt;.&lt;/span&gt;&lt;span class="keyword token"&gt;set&lt;/span&gt;&lt;span class="punctuation token"&gt;(&lt;/span&gt;&lt;span class="string token"&gt;&amp;#39;resource_rate_actual&amp;#39;&lt;/span&gt;&lt;span class="punctuation token"&gt;,&lt;/span&gt; &lt;span class="keyword token"&gt;this&lt;/span&gt;&lt;span class="punctuation token"&gt;.&lt;/span&gt;model&lt;span class="punctuation token"&gt;.&lt;/span&gt;&lt;span class="keyword token"&gt;get&lt;/span&gt;&lt;span class="punctuation token"&gt;(&lt;/span&gt;&lt;span class="string token"&gt;&amp;#39;project_manager_rate_c&amp;#39;&lt;/span&gt;&lt;span class="punctuation token"&gt;)&lt;/span&gt;&lt;span class="punctuation token"&gt;,&lt;/span&gt;&lt;span class="punctuation token"&gt;{&lt;/span&gt;silent&lt;span class="punctuation token"&gt;:&lt;/span&gt; &lt;span class="keyword token"&gt;true&lt;/span&gt;&lt;span class="punctuation token"&gt;}&lt;/span&gt;&lt;span class="punctuation token"&gt;)&lt;/span&gt;&lt;span class="punctuation token"&gt;;&lt;/span&gt;&lt;span class="line-numbers-rows"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;and similarly for your other case in the switch statement.&lt;/p&gt;&lt;p&gt;Hope this helps,&lt;/p&gt;&lt;p&gt;FrancescaS&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Changes in Sidecar model not reflected in Sugar bean</title><link>https://sugarclub.sugarcrm.com/thread/7497?ContentTypeID=1</link><pubDate>Wed, 11 Mar 2020 00:11:18 GMT</pubDate><guid isPermaLink="false">5c521d64-519d-47a6-9065-134618b211bf:96aa4a42-b735-4fff-86ed-a153e2629221</guid><dc:creator>Enrico Simonetti</dc:creator><description>&lt;p&gt;From memory you would need to have the field in the view to be able to save the value from the UI. I believe you&amp;nbsp;should be able to use the keyword &amp;quot;related_fields&amp;quot; on the php view to have the field available in the js view without seeing it in the UI.&lt;/p&gt;&lt;p&gt;Try it out and is if that works.&lt;/p&gt;&lt;p&gt;An alternative (possibly better) is to see if you can achieve this exact change&amp;nbsp;without customising the code, just with &lt;a href="https://support.sugarcrm.com/Knowledge_Base/Studio_and_Module_Builder/Sugar_Logic/index.html" rel="nofollow" target="_blank"&gt;Sugar Logic&lt;/a&gt; and/or&amp;nbsp;&lt;a href="https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_9.3/Architecture/Extensions/Dependencies/index.html" rel="nofollow" target="_blank"&gt;Dependencies&lt;/a&gt;&lt;/p&gt;&lt;p&gt;Hope it helps&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Changes in Sidecar model not reflected in Sugar bean</title><link>https://sugarclub.sugarcrm.com/thread/7495?ContentTypeID=1</link><pubDate>Fri, 06 Mar 2020 06:19:40 GMT</pubDate><guid isPermaLink="false">5c521d64-519d-47a6-9065-134618b211bf:3dd6dfb9-2e83-42f1-8c3a-5ea695915063</guid><dc:creator>Maryam Aslam</dc:creator><description>&lt;p&gt;Hi &lt;a href="https://sugarclub.sugarcrm.com/members/yury"&gt;Yury Voloshin&lt;/a&gt;,&lt;/p&gt;&lt;p&gt;You are right that&amp;nbsp;&lt;span style="color:#000000;background-color:#ffffff;"&gt;any changes to the model are reflected in the bean. I never used logic hooks to manage my frontend and backend separately. I guess the issue is maybe this.model.set is executing before this.model.get. Well, it also should not happen because inner code executes first.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;background-color:#ffffff;"&gt;Please try this:&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;background-color:#ffffff;"&gt;var pro_manager = &lt;span style="background-color:#f6f6f6;"&gt;this.model.get(&amp;#39;project_manager_rate_c&amp;#39;);&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="background-color:#f6f6f6;color:#000000;"&gt;&lt;span&gt;this.model.set(&amp;#39;resource_rate_actual&amp;#39;, &lt;span style="background-color:#ffffff;"&gt;pro_manager&lt;/span&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="background-color:#f6f6f6;color:#000000;"&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="background-color:#f6f6f6;color:#000000;"&gt;&lt;span&gt;One more thing is that if you are setting these values for the creation of the new record then add the same code for the CreateView as well in create.js file. Otherwise, it will only work just for the edit/save not for the create/save.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="background-color:#f6f6f6;color:#000000;"&gt;&lt;/span&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;span style="background-color:#f6f6f6;color:#000000;"&gt;&lt;/span&gt;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>