<?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 Map variable of record producer in CSM forum</title>
    <link>https://www.servicenow.com/community/csm-forum/map-variable-of-record-producer/m-p/3073520#M40153</link>
    <description>&lt;P&gt;We are creating a record producer to capture defects, however we want to map the variables back to the defect record it creates, I know we need to do this in the record producer screp but just need some help with the logic, basically want to map the following:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;requested_by to u_requested_by field on defect form&lt;/P&gt;&lt;P&gt;u_summary_of_the_defect to short_description field on defect form&lt;/P&gt;&lt;P&gt;u_impact_on_users to impact_on_users field on the defect form&lt;/P&gt;&lt;P&gt;u_priority to u_priority field on the defect form&lt;/P&gt;&lt;P&gt;We want to below all mapped to the Description field on the defect form however with headings and spacing in between.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Summary of the Defect:&lt;BR /&gt;u_summary_of_the_defect&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Steps to Reproduce:&lt;BR /&gt;u_steps_to_reproduce&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Expected Behavior:&lt;BR /&gt;u_expected_behavior&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Actual Behavior:&lt;BR /&gt;u_actual_behavior&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;u_attachments (I'm assuming any attachments uploaded here will just automatically add as attachments to the defect form?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 15 Oct 2024 00:10:12 GMT</pubDate>
    <dc:creator>Greg L</dc:creator>
    <dc:date>2024-10-15T00:10:12Z</dc:date>
    <item>
      <title>Map variable of record producer</title>
      <link>https://www.servicenow.com/community/csm-forum/map-variable-of-record-producer/m-p/3073520#M40153</link>
      <description>&lt;P&gt;We are creating a record producer to capture defects, however we want to map the variables back to the defect record it creates, I know we need to do this in the record producer screp but just need some help with the logic, basically want to map the following:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;requested_by to u_requested_by field on defect form&lt;/P&gt;&lt;P&gt;u_summary_of_the_defect to short_description field on defect form&lt;/P&gt;&lt;P&gt;u_impact_on_users to impact_on_users field on the defect form&lt;/P&gt;&lt;P&gt;u_priority to u_priority field on the defect form&lt;/P&gt;&lt;P&gt;We want to below all mapped to the Description field on the defect form however with headings and spacing in between.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Summary of the Defect:&lt;BR /&gt;u_summary_of_the_defect&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Steps to Reproduce:&lt;BR /&gt;u_steps_to_reproduce&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Expected Behavior:&lt;BR /&gt;u_expected_behavior&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Actual Behavior:&lt;BR /&gt;u_actual_behavior&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;u_attachments (I'm assuming any attachments uploaded here will just automatically add as attachments to the defect form?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 15 Oct 2024 00:10:12 GMT</pubDate>
      <guid>https://www.servicenow.com/community/csm-forum/map-variable-of-record-producer/m-p/3073520#M40153</guid>
      <dc:creator>Greg L</dc:creator>
      <dc:date>2024-10-15T00:10:12Z</dc:date>
    </item>
    <item>
      <title>Re: Map variable of record producer</title>
      <link>https://www.servicenow.com/community/csm-forum/map-variable-of-record-producer/m-p/3073548#M40155</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://www.servicenow.com/community/user/viewprofilepage/user-id/192301"&gt;@Greg L&lt;/a&gt;&lt;BR /&gt;&lt;BR /&gt;To map the variables from your record producer to the defect form in ServiceNow, you'll need to use a script in the Record Producer's script field. Here's how you can structure it.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;// Set fields on the defect record

current.u_requested_by = producer.requested_by;

current.short_description = producer.u_summary_of_the_defect;

current.impact_on_users = producer.u_impact_on_users;

current.u_priority = producer.u_priority;

// Attachments should automatically carry over if you are using out-of-the-box attachment functionality.&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;producer.variable_name: Retrieves the value from the record producer variables.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;current.field_name: Maps the value to the target field on the defect form.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;"If you found my answer helpful, please give it a like and mark it as the accepted solution. It helps others find the solution more easily and supports the community!"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks &amp;amp; Regards,&lt;/P&gt;&lt;P&gt;Barath.P&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 15 Oct 2024 02:01:37 GMT</pubDate>
      <guid>https://www.servicenow.com/community/csm-forum/map-variable-of-record-producer/m-p/3073548#M40155</guid>
      <dc:creator>Barath P</dc:creator>
      <dc:date>2024-10-15T02:01:37Z</dc:date>
    </item>
    <item>
      <title>Re: Map variable of record producer</title>
      <link>https://www.servicenow.com/community/csm-forum/map-variable-of-record-producer/m-p/3073561#M40157</link>
      <description>&lt;P&gt;Thanks so much, how about the mapping to the Description as per the below:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;We want to below all mapped to the Description field on the defect form however with headings and spacing in between.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Summary of the Defect:&lt;BR /&gt;u_summary_of_the_defect&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Steps to Reproduce:&lt;BR /&gt;u_steps_to_reproduce&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Expected Behavior:&lt;BR /&gt;u_expected_behavior&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Actual Behavior:&lt;BR /&gt;u_actual_behavior&lt;/P&gt;</description>
      <pubDate>Tue, 15 Oct 2024 02:20:56 GMT</pubDate>
      <guid>https://www.servicenow.com/community/csm-forum/map-variable-of-record-producer/m-p/3073561#M40157</guid>
      <dc:creator>Greg L</dc:creator>
      <dc:date>2024-10-15T02:20:56Z</dc:date>
    </item>
    <item>
      <title>Re: Map variable of record producer</title>
      <link>https://www.servicenow.com/community/csm-forum/map-variable-of-record-producer/m-p/3073568#M40158</link>
      <description>&lt;P&gt;&lt;a href="https://www.servicenow.com/community/user/viewprofilepage/user-id/192301"&gt;@Greg L&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;You can try below script:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var description = '';
description += 'Summary of the Defect:\n';
description += producer.u_summary_of_the_defect + '\n\n';

description += 'Steps to Reproduce:\n';
description += producer.u_steps_to_reproduce + '\n\n';

description += 'Expected Behavior:\n';
description += producer.u_expected_behavior + '\n\n';

description += 'Actual Behavior:\n';
description += producer.u_actual_behavior + '\n\n';

// Set the description field on the defect form
current.description = description;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;"If you found my answer helpful, please give it a like and mark it as the accepted solution. It helps others find the solution more easily and supports the community!"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks &amp;amp; Regards,&lt;/P&gt;&lt;P&gt;Barath.P&lt;/P&gt;</description>
      <pubDate>Tue, 15 Oct 2024 02:31:30 GMT</pubDate>
      <guid>https://www.servicenow.com/community/csm-forum/map-variable-of-record-producer/m-p/3073568#M40158</guid>
      <dc:creator>Barath P</dc:creator>
      <dc:date>2024-10-15T02:31:30Z</dc:date>
    </item>
    <item>
      <title>Re: Map variable of record producer</title>
      <link>https://www.servicenow.com/community/csm-forum/map-variable-of-record-producer/m-p/3073569#M40159</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://www.servicenow.com/community/user/viewprofilepage/user-id/192301"&gt;@Greg L&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;You can map the record producer variables to the defect record in the record producer script using server-side code. Here's an example of how you can handle this mapping:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;STRONG&gt;Mapping Individual Fields:&lt;/STRONG&gt; You'll directly assign the variables from the record producer to the fields in the defect record.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;STRONG&gt;Mapping Multiple Variables to the Description Field:&lt;/STRONG&gt; For this, you can concatenate the values from multiple variables with headings and line breaks.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;STRONG&gt;Handling Attachments:&lt;/STRONG&gt; Attachments uploaded to the record producer should automatically transfer to the defect record.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Here's the logic you need to add to the record producer script:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;(function() {
    // Create a new defect record
    var defect = new GlideRecord('u_defect');  // Replace with your defect table name
    defect.initialize();

    // Map the individual fields
    defect.u_requested_by = producer.requested_by;
    defect.short_description = producer.u_summary_of_the_defect;
    defect.u_impact_on_users = producer.u_impact_on_users;
    defect.u_priority = producer.u_priority;

    // Concatenate fields for the Description field
    var description = '';
    description += 'Summary of the Defect:\n' + producer.u_summary_of_the_defect + '\n\n';
    description += 'Steps to Reproduce:\n' + producer.u_steps_to_reproduce + '\n\n';
    description += 'Expected Behavior:\n' + producer.u_expected_behavior + '\n\n';
    description += 'Actual Behavior:\n' + producer.u_actual_behavior + '\n\n';
    defect.description = description;

    // Insert the defect record
    var defectSysId = defect.insert();

    // Handle attachments (attachments automatically move to the created record)
    gs.addInfoMessage('Defect record created with ID: ' + defectSysId);
})();&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Key Points:&lt;/SPAN&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;SPAN&gt;Field Mapping: Fields like u_requested_by, short_description, and u_priority are mapped directly from the record producer to the defect form.&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN&gt;Description Field: The fields are concatenated with headings for the description field.&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN&gt;Attachments: As long as attachments are added to the record producer, they should automatically attach to the defect record.&lt;/SPAN&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;SPAN&gt;"If you found my answer helpful, please give it a like and mark it as the accepted solution. It helps others find the solution more easily and supports the community!"&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thank You&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Juhi Poddar&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 15 Oct 2024 02:32:04 GMT</pubDate>
      <guid>https://www.servicenow.com/community/csm-forum/map-variable-of-record-producer/m-p/3073569#M40159</guid>
      <dc:creator>Juhi Poddar</dc:creator>
      <dc:date>2024-10-15T02:32:04Z</dc:date>
    </item>
  </channel>
</rss>

