Populate assignment group field through workflow based on Cat Item's Select Box values

ronro2
Tera Contributor

Hey guys!

I have a catalog item, the following one with field called "u_assignment_group". You can see my cat item here below in the screenshot:

ronro2_0-1732018657817.png

I want to populate the corresponding field called "assignment_group" in the sc_req_item 

ronro2_1-1732019016263.png

So if i in the cat item form choose select box option 'minor_update_doc_plan' it should populate the sc_req_item with assignment group 82f2d480b5185210068bdbe3807c4f29. There is this workflow in the catalog item, with this script (this is a cutout), which is not working: 



 
current.opened_by = current.variables.opened_by;
current.u_telefonnummer = current.variables.telefonnummer;
current.assignment_group = current.cat_item.u_assignment_group;
current.u_personnummer = current.variables.social_security_number;
current.business_service = current.cat_item.u_service_offering;


// Cat item "a306fda71ba3d4106de6f7c4464bcb09". Map case_type to assignment group
if (current.cat_item == 'a306fda71ba3d4106de6f7c4464bcb09') {
    // Kontrollera vƤrdet av case_type och sƤtt assignment_group dƤrefter
    switch (current.variables.case_type) {
        case 'minor_update_doc_plan':
            current.assignment_group = '82f2d480b5185210068bdbe3807c4f29';
            break;
        case 'update_site_templ_definition':
        case 'configure_new_site_template_definition':
            current.assignment_group = 'a6721440b5185210068bdbe3807c4fc0';
            break;
        case 'annual_update_doc_mgmnt_plan':
            current.assignment_group = '82f2d480b5185210068bdbe3807c4f29';
            break;
        default:
            // Hantera eventuella andra fall eller lƤmna tomt
            break;
    }


Thanks in advance! 

1 ACCEPTED SOLUTION

vMalhotra
Tera Guru

Hi,

Your script seems to be correct. Try commenting the first two lines of this script or put logs in the script to check if the line 3 is being executed.

View solution in original post

2 REPLIES 2

vMalhotra
Tera Guru

Hi,

Your script seems to be correct. Try commenting the first two lines of this script or put logs in the script to check if the line 3 is being executed.

ronro2
Tera Contributor

You were right about it being correct. 

I had to use toString() function. 

    switch (current.variables.case_type.toString()) {