Idea Portal + Record Producers and Categories

alithia
Tera Contributor

I've got a record producer to build out idea submissions. I'd like those ideas to post to the ideas portal which requires that an equivalent record be created in im_m2m_idea_category. My form is submitting to the idea table correctly, and I can see it in the backend, I'm just not sure how to go about setting the values for the im_m2m_idea_category on submission so that we don't need to go manually change those ideas (which works, but it's not ideal longer term).

1 REPLY 1

Jennifer Red
Tera Expert

I know this is old, but I wanted to respond in case others search and find this like I did. I had already created a "Category" field on my record producer to capture the information that matches the values on the im_m2m_idea_category table. Below is the part of the code I put into my record producer script to create the records in im_m2m_idea_category.

 

// Retrieve the sys_id values of producer.category as a string and split it into an array
var categorySysIds = producer.category.getValue().split(',');

// Loop through each category in producer.category
for (var i = 0; i < categorySysIds.length; i++) {
    var ideaCategory = new GlideRecord('im_m2m_idea_category');
    ideaCategory.initialize();
    ideaCategory.idea = current.sys_id;
    ideaCategory.category_id = categorySysIds[i];
    ideaCategory.category_table.setDisplayValue('im_category');
    ideaCategory.insert();
}