Help in my code

Arthur Sanchez
Giga Guru

I'm trying to create a code where, every time a ticket is created, the queue field is updated, and as it's going to be a lot, I thought about creating a client script instead of using flow, + I'm not able to change the queue field

 

 

// Client Script to direct a ticket to a queue based on the fields filled in the catalog tree
function onSubmit() {
    var area = g_form.getValue('area');
    var system = g_form.getValue('system');
    var serviceType = g_form.getValue('service_type');
    
    // Determine the queue based on the field values
    var queueValue = determineQueue(area, system, serviceType);
    
    // Update the 'Queue' field with the correct value
    g_form.setValue('queue', queueValue);
}

// Function to determine the queue value based on the field values
function determineQueue(area, system, serviceType) {
    // If the area is TI, the system is "app", and the service type meets the criteria
    if (area === 'ti' && system === 'app' &&
        (serviceType === 'maintenance_ti' || serviceType === 'installation_ti' ||
         serviceType === 'configuration_ti' || serviceType === 'customization_ti')) {
        return 'app_n1'; // Queue value for app_n1
    }
    
    // If no case matches, do not return anything
    return ''; // Returns an empty string when no case matches
}

 

 

 if the area field is 'ti' and if the system field is 'app' what if the service_typer field is any of: malntenance_ti, installation_ti, configuration_ti, customizetlon_ti, the queue value must be app_n1
Captura de tela 2024-05-06 163001.png

 

11 REPLIES 11

chrisperry
Giga Sage

Is this 'Queue' field on the record producer form that is submitted to create the ticket record? If it is not on the record producer form, then you will need to add it to the form (and hide it via catalog UI policy if it shouldn't be visible) for it to be available to set from client script.

If this answer is helpful please mark correct and helpful!

Regards,
Chris Perry

This field is of type choice, I created it in the application via Studio

Captura de tela 2024-05-06 171043.pngCaptura de tela 2024-05-06 171102.png

How are you creating the record? Is it from a record producer or are you just creating a new record from the back-end w/ New button?

If this answer is helpful please mark correct and helpful!

Regards,
Chris Perry

Dude, I made the queue field where it has these options, it's just a form option created in studio that I'm trying to make a client script