Record Producer script issue

Jeanne Goodman
Giga Expert

This script works great except it doesn't change the type 

(function() {
    // Set the caller to the person who submitted the request
    current.caller_id = gs.getUserID();
   
    // Set the category and subcategory
    current.category = 'Telecom';
    current.subcategory = 'Abt Phone #';
   
    // Get the request type from the record producer
    var requestType = producer.request_type; // Ensure this matches the field name in the record producer
    gs.log('Request Type: ' + requestType);
   
    // Set the type based on the user's selection
    switch (requestType) {
        case '792783c247b59a108dda98d3616d43ec':
            current.u_type = 'Disable/Remove';
            gs.log('Set u_type to Disable/Remove');
            break;
        case '3a8c3d0e47319a108dda98d3616d43ad':
            current.u_type = 'New';
            gs.log('Set u_type to New');
            break;
        case 'f93c9d8f47759e108dda98d3616d4305':
            current.u_type = 'Retain';
            gs.log('Set u_type to Retain');
            break;
        case '3a8c3d0e47319a108dda98d3616d43af':
            current.u_type = 'Reissue';
            gs.log('Set u_type to Reissue');
            break;
        default:
            current.u_type = '-None-';
    }


// Set other fields
current.u_type_of_request = 'Abt Request';
current.impact = '3 - Low';
current.urgency = '3 - Low';
current.contact_type = 'self-service';
current.assignment_group = 'c70483890058300008e976c2ab56f959';

// Set Short description
current.short_description = requestType + ' request for ' + gs.getUserDisplayName();

// Set the description to capture all options selected by the user
var description = 'Request Type: ' + requestType + '\n' +
                  'Phone Number: ' + producer.u_phone_number + '\n' +
                  'Business Justification: ' + producer.business_justification + '\n' +
                  'Type: ' + producer.request_type + ' ' + current.u_type;

   
   
// if (requestType == producer.request_type) {
//   description += 'The values are loosely equal.\n';
// } else {
//   description += 'The values are different.\n';
// }
    // Add comments if they exist
    if (producer.comments) {
        description += '\nComments: ' + producer.comments;
    }
   
    current.description = description;
})();
9 REPLIES 9

JenniferRah
Mega Sage

A few things stand out.

 

Is the issue in the u_type field or u_type_of_request?

 

What type of field is u_type (assuming that's the one with the issue)? Are the values you are setting the Labels or the Values? You need to set the field to the internal value. 

 

And where is this being run? You mention "producer" so I'm guessing it's running in the Record Producer script field. But none of my scripts like this are enclosed in a function(){}. I'm wondering if any of your fields are being set? Is it just the type one that is having the issue?

Thanks so much for chiming in.
I'm there's a Record producer where the user selects to either
Get a new license, give up a license, reinstate an existing license, or ask that a license.

When the user submits it, all of the fields in the incident are working correctly EXCEPT the type (current.u_type)
I've run all of the tests that I could think of but it fails every case and displays the default answer. but I can't see why it's failing the cases. If you see there's a variable called requestType that appears as expected when I ask it to appear in the description, but not in that case.

Can you show some screen shots of the u_type field and its choices so I can see how it's configured?

Sure! Appreciate the help!

JeanneGoodman_0-1732590203889.png

Does this help?

JeanneGoodman_1-1732590418963.png