<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>question Re: Onbefore Transform map not updating the record, only inserting even though matches with theCondi in GRC forum</title>
    <link>https://www.servicenow.com/community/grc-forum/onbefore-transform-map-not-updating-the-record-only-inserting/m-p/2977848#M17454</link>
    <description>&lt;P&gt;Hi&amp;nbsp;@Community Alums&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Create a onBefore Transform Script and use the code below:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;if(action == 'insert'){
ignore = true;
}&lt;/LI-CODE&gt;&lt;P&gt;Also make a field coalesce &lt;STRONG&gt;true&amp;nbsp;&lt;/STRONG&gt;through which you want to update the record.&lt;BR /&gt;&lt;STRONG&gt;Please Mark this Helpful and Accepted Solution. If this Helps you to understand. This will help both the community and me..&lt;BR /&gt;- Keep Learning ‌‌&lt;BR /&gt;Thanks &amp;amp; Regards&lt;BR /&gt;Deepak Sharma&amp;nbsp;&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 02 Jul 2024 03:18:42 GMT</pubDate>
    <dc:creator>Deepak Shaerma</dc:creator>
    <dc:date>2024-07-02T03:18:42Z</dc:date>
    <item>
      <title>Onbefore Transform map not updating the record, only inserting even though matches with theCondition</title>
      <link>https://www.servicenow.com/community/grc-forum/onbefore-transform-map-not-updating-the-record-only-inserting/m-p/2977705#M17448</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Following is my field map&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="PradeepPatel1_1-1719862773395.png" style="width: 400px;"&gt;&lt;img src="https://www.servicenow.com/community/image/serverpage/image-id/368848iF4919AA70F53469A/image-size/medium?v=v2&amp;amp;px=400" role="button" title="PradeepPatel1_1-1719862773395.png" alt="PradeepPatel1_1-1719862773395.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;following is onbefore script&lt;/P&gt;&lt;P&gt;here I am checking if entity and current_ram combination exits, if yes then update the record.&lt;/P&gt;&lt;P&gt;I am mapping ram with the expected ram&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="PradeepPatel1_2-1719862981532.png" style="width: 400px;"&gt;&lt;img src="https://www.servicenow.com/community/image/serverpage/image-id/368850i7AD729C66F5F25CC/image-size/medium?v=v2&amp;amp;px=400" role="button" title="PradeepPatel1_2-1719862981532.png" alt="PradeepPatel1_2-1719862981532.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;if combination does not exits then create new record&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="PradeepPatel1_3-1719863117694.png" style="width: 400px;"&gt;&lt;img src="https://www.servicenow.com/community/image/serverpage/image-id/368851i329B4EDEE76760C3/image-size/medium?v=v2&amp;amp;px=400" role="button" title="PradeepPatel1_3-1719863117694.png" alt="PradeepPatel1_3-1719863117694.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;for reference this is the table and following is the form&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="PradeepPatel1_4-1719863179173.png" style="width: 400px;"&gt;&lt;img src="https://www.servicenow.com/community/image/serverpage/image-id/368852i7F01EA454752783D/image-size/medium?v=v2&amp;amp;px=400" role="button" title="PradeepPatel1_4-1719863179173.png" alt="PradeepPatel1_4-1719863179173.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Following is the script&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;function&lt;/SPAN&gt;&lt;SPAN&gt; runTransformScript(source, map, log, target &lt;/SPAN&gt;&lt;SPAN&gt;/*undefined onStart*/&lt;/SPAN&gt;&lt;SPAN&gt; ) {&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;var&lt;/SPAN&gt;&lt;SPAN&gt; up = &lt;/SPAN&gt;&lt;SPAN&gt;new&lt;/SPAN&gt; &lt;SPAN&gt;GlideRecord&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;"sn_risk_advanced_risk_assessment_scope"&lt;/SPAN&gt;&lt;SPAN&gt;);&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; up.addEncodedQuery(&lt;/SPAN&gt;&lt;SPAN&gt;"entity.nameSTARTSWITH"&lt;/SPAN&gt;&lt;SPAN&gt;+ source.u_entity + &lt;/SPAN&gt;&lt;SPAN&gt;"^risk_assessment_methodology.nameSTARTSWITH"&lt;/SPAN&gt;&lt;SPAN&gt; + source.u_current_ram);&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; up.query();&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;if&lt;/SPAN&gt;&lt;SPAN&gt;(up.next())&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; {&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; action = &lt;/SPAN&gt;&lt;SPAN&gt;'update'&lt;/SPAN&gt;&lt;SPAN&gt;;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; }&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;else&lt;/SPAN&gt;&lt;SPAN&gt;{&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ignore = &lt;/SPAN&gt;&lt;SPAN&gt;true&lt;/SPAN&gt;&lt;SPAN&gt;;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; }&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;})(source, map, log, target);&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 01 Jul 2024 19:47:36 GMT</pubDate>
      <guid>https://www.servicenow.com/community/grc-forum/onbefore-transform-map-not-updating-the-record-only-inserting/m-p/2977705#M17448</guid>
      <dc:creator>Community Alums</dc:creator>
      <dc:date>2024-07-01T19:47:36Z</dc:date>
    </item>
    <item>
      <title>Re: Onbefore Transform map not updating the record, only inserting even though matches with theCondi</title>
      <link>https://www.servicenow.com/community/grc-forum/onbefore-transform-map-not-updating-the-record-only-inserting/m-p/2977754#M17452</link>
      <description>&lt;P&gt;Hi&amp;nbsp;@Community Alums&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You can just not use a scripted action and just put your u_expected_ram and u_entity as a Coalesce fields, this will have a similar result:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Marco0o1_0-1719868229349.png" style="width: 400px;"&gt;&lt;img src="https://www.servicenow.com/community/image/serverpage/image-id/368866i42B66305CD71999B/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Marco0o1_0-1719868229349.png" alt="Marco0o1_0-1719868229349.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;If that doesnt work to you maybe you can try not use a onbefore script and change to just run the script at the start because your script[onBefore] run when the record was already created:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Marco0o1_2-1719868411426.png" style="width: 400px;"&gt;&lt;img src="https://www.servicenow.com/community/image/serverpage/image-id/368868i88225FAD6585D30B/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Marco0o1_2-1719868411426.png" alt="Marco0o1_2-1719868411426.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Marco&lt;/P&gt;</description>
      <pubDate>Mon, 01 Jul 2024 21:14:12 GMT</pubDate>
      <guid>https://www.servicenow.com/community/grc-forum/onbefore-transform-map-not-updating-the-record-only-inserting/m-p/2977754#M17452</guid>
      <dc:creator>Marco0o1</dc:creator>
      <dc:date>2024-07-01T21:14:12Z</dc:date>
    </item>
    <item>
      <title>Re: Onbefore Transform map not updating the record, only inserting even though matches with theCondi</title>
      <link>https://www.servicenow.com/community/grc-forum/onbefore-transform-map-not-updating-the-record-only-inserting/m-p/2977840#M17453</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://www.servicenow.com/community/user/viewprofilepage/user-id/518497"&gt;@Marco0o1&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;Tried running through run script still inserting record. I just want to update the record rather than inserting it.&lt;/P&gt;</description>
      <pubDate>Tue, 02 Jul 2024 02:49:12 GMT</pubDate>
      <guid>https://www.servicenow.com/community/grc-forum/onbefore-transform-map-not-updating-the-record-only-inserting/m-p/2977840#M17453</guid>
      <dc:creator>Community Alums</dc:creator>
      <dc:date>2024-07-02T02:49:12Z</dc:date>
    </item>
    <item>
      <title>Re: Onbefore Transform map not updating the record, only inserting even though matches with theCondi</title>
      <link>https://www.servicenow.com/community/grc-forum/onbefore-transform-map-not-updating-the-record-only-inserting/m-p/2977848#M17454</link>
      <description>&lt;P&gt;Hi&amp;nbsp;@Community Alums&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Create a onBefore Transform Script and use the code below:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;if(action == 'insert'){
ignore = true;
}&lt;/LI-CODE&gt;&lt;P&gt;Also make a field coalesce &lt;STRONG&gt;true&amp;nbsp;&lt;/STRONG&gt;through which you want to update the record.&lt;BR /&gt;&lt;STRONG&gt;Please Mark this Helpful and Accepted Solution. If this Helps you to understand. This will help both the community and me..&lt;BR /&gt;- Keep Learning ‌‌&lt;BR /&gt;Thanks &amp;amp; Regards&lt;BR /&gt;Deepak Sharma&amp;nbsp;&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 02 Jul 2024 03:18:42 GMT</pubDate>
      <guid>https://www.servicenow.com/community/grc-forum/onbefore-transform-map-not-updating-the-record-only-inserting/m-p/2977848#M17454</guid>
      <dc:creator>Deepak Shaerma</dc:creator>
      <dc:date>2024-07-02T03:18:42Z</dc:date>
    </item>
    <item>
      <title>Re: Onbefore Transform map not updating the record, only inserting even though matches with theCondi</title>
      <link>https://www.servicenow.com/community/grc-forum/onbefore-transform-map-not-updating-the-record-only-inserting/m-p/2977857#M17455</link>
      <description>&lt;P&gt;Hi &lt;a href="https://www.servicenow.com/community/user/viewprofilepage/user-id/435716"&gt;@Deepak Shaerma&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Actually I can not use coalesce here, I want to check current_ram column with ram from target table, if combination exists then update it with expected RAM, can I update it in the script rather than Ignoring it.&lt;/P&gt;</description>
      <pubDate>Tue, 02 Jul 2024 03:32:29 GMT</pubDate>
      <guid>https://www.servicenow.com/community/grc-forum/onbefore-transform-map-not-updating-the-record-only-inserting/m-p/2977857#M17455</guid>
      <dc:creator>Community Alums</dc:creator>
      <dc:date>2024-07-02T03:32:29Z</dc:date>
    </item>
    <item>
      <title>Re: Onbefore Transform map not updating the record, only inserting even though matches with theCondi</title>
      <link>https://www.servicenow.com/community/grc-forum/onbefore-transform-map-not-updating-the-record-only-inserting/m-p/2977861#M17456</link>
      <description>&lt;P&gt;try using this script"&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var entityName = source.u_entity;
var currentRAM = source.u_current_ram;

// Create a new GlideRecord instance for the target table
var up = new GlideRecord("sn_risk_advanced_risk_assessment_scope");

// Add query to find records where entity name and risk assessment methodology match
up.addEncodedQuery("entity.nameSTARTSWITH" + entityName + "^risk_assessment_methodology.nameSTARTSWITH" + currentRAM);
up.query();

// If the record exists, update it
if (up.next()) {
    // Map the existing record fields to the target object to perform the update
    target.initialize();
    for (var field in source) {
        if (source.hasOwnProperty(field) &amp;amp;&amp;amp; target.isValidField(field)) {
            target[field] = source[field];
        }
    }
    target.setWorkflow(false); // Disable business rules and workflows
    target.autoSysFields(false); // Prevent automatic updating of sys fields like sys_updated_by and sys_updated_on
    target.update(); // Save the changes

    action == 'update';
}
// Else, ignore the record creation
else {
    ignore = true;
}&lt;/LI-CODE&gt;&lt;P&gt;&lt;STRONG&gt;Please Mark this Helpful and Accepted Solution. If this Helps you to understand. This will help both the community and me..&lt;BR /&gt;- Keep Learning ‌‌&lt;BR /&gt;Thanks &amp;amp; Regards&lt;BR /&gt;Deepak Sharma&amp;nbsp;&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 02 Jul 2024 03:40:47 GMT</pubDate>
      <guid>https://www.servicenow.com/community/grc-forum/onbefore-transform-map-not-updating-the-record-only-inserting/m-p/2977861#M17456</guid>
      <dc:creator>Deepak Shaerma</dc:creator>
      <dc:date>2024-07-02T03:40:47Z</dc:date>
    </item>
    <item>
      <title>Re: Onbefore Transform map not updating the record, only inserting even though matches with theCondi</title>
      <link>https://www.servicenow.com/community/grc-forum/onbefore-transform-map-not-updating-the-record-only-inserting/m-p/2977944#M17457</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://www.servicenow.com/community/user/viewprofilepage/user-id/435716"&gt;@Deepak Shaerma&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;target.update I can not use, they are having their best practice set while saving the code, throws error message target.update can not be used in onbefore&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 02 Jul 2024 05:56:22 GMT</pubDate>
      <guid>https://www.servicenow.com/community/grc-forum/onbefore-transform-map-not-updating-the-record-only-inserting/m-p/2977944#M17457</guid>
      <dc:creator>Community Alums</dc:creator>
      <dc:date>2024-07-02T05:56:22Z</dc:date>
    </item>
  </channel>
</rss>

