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

This field is free, there is no acl, ui policy, or business rule linked to it, and I don't understand why it doesn't change

 

 

function onSubmit() {
    // Obter o valor do campo 'service_type'
    var serviceType = g_form.getValue('service_type');
    
    // Verificar se o valor do campo 'service_type' é 'configuration_ti'
    if (serviceType === 'configuration_ti') {
        // Definir o valor do campo 'queue' como 'app_n1'
        g_form.setValue('queue', 'app_n1');
    }
}

I'm testing this section but it's not working, nothing happens when the tick is created, but with this section:

function onLoad() {
    // Obter o valor do campo 'service_type'
    var serviceType = g_form.getValue('service_type');
    
    // Verificar se o valor do campo 'service_type' é 'configuration_ti'
    if (serviceType === 'configuration_ti') {
        // Definir o valor do campo 'queue' como 'app_n1'
        g_form.setValue('queue', 'app_n1');
    }
}

 

 

it works, the problem is that every time it goes to app_n1 even when changing the queue manually, and I don't understand why onSubmit didn't work but onLoad did?