Create an Idea from a record producer

Jennifer Red
Tera Expert

I've been asked to add more questions to the Idea Portal. Since it's not advised to modify OOB behavior, I thought it might be best to use a record producer in place of the original Idea Portal. I have the record producer part built out and it functions like any other. BUT when it tries to create an Idea on the Idea table, it gives an error "Please enter close notes before you close the idea." in the service portal. This keeps the Idea from ever being created. If I go into the script of the RP and put close_notes it will create the Idea, but it goes to the Completed state pretty quickly. Any ideas on what would cause this to happen? I've looked at business rules, ui actions, flows, etc. I don't see anything that would force an Idea to a Completed state after creation.

1 ACCEPTED SOLUTION

Jennifer Red
Tera Expert

ServiceNow support advised me that the "category" field was mapped to "active" and that was causing the issue. Once that mapping was removed, the issue was resolved.

View solution in original post

6 REPLIES 6

Benjamin A
Mega Sage

Hi Jennifer,

 

I'd assume this has something to do with the way the record is being initialized/created by the record producer. Have you tried setting the state of the idea in the script or have you tried using a template perhaps?

 

Hope this helps,

Ben 

I was initially setting the state to 1 which is Submitted on the im_idea_core table. I'm assuming that is the main idea table. There's not any states set specifically for the idea table itself.

It actually starts out as a 1 because I'm logging it, but it ends up becoming a 3 almost instantaneously.

Jennifer Red
Tera Expert

I've changed my code to the below. This is allowing the Idea to be created, but it still gives an error message to enter close notes before closing the idea.

(function producerScript() {
    // Create a new GlideRecord for the Idea table
    var idea = new GlideRecord('idea');
    idea.initialize();

    // Set the fields using the variables from the record producer
    idea.short_description = producer.title;
    idea.category = producer.category;
    idea.state = 1; // Set the initial state
   
    idea.idea_description = '1. What is the current problem prompting this Idea? ' + producer.what_is_the_current_problem_prompting_this_idea';

    // Insert the new idea record
    var ideaSysId = idea.insert();

    // Redirect to the newly created Idea record in the Service Portal
    producer.portal_redirect = '/sp?id=view_idea&sysparm_idea_id=' + ideaSysId + '&sysparm_idea_table=idea&sysparm_module_id=internal';
})();