I need to populate a variable field on the task form if the assignment group changes.

ronyates
Tera Guru

I need to change a field on the task form if the assignment group changes. The field is a variable field called new_assingment_group. I need this field populated with the new assignment group for an upstream task in the workflow, but I cannot seem to get it to work.

 

 

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var ba_group = g_form.getValue('assignment_group',callMe);

function callMe(ba_group)
g_form.getReference('assignment_group', function(callMe) {
if (callMe) {
g_form.setValue('new_assignment_group',ba_group);
}
});
}

1 ACCEPTED SOLUTION

I figured out why my initinal code was not working. The semi colon was missing from this line. g_form.getReference('assignment_group', function(user) {
if (user)

Should have been 

g_form.getReference('assignment_group', function(user) {
if (user);

function onChange(control, oldValue, newValue, isLoading) {
    if (isLoading || newValue == '') {
        return;
    }

    // Type appropriate comment here, and begin script below
    var ba_group = g_form.getValue('assignment_group');

	
    // Use getReference with callback
     g_form.getReference('assignment_group', function(user) {
        if (user); {
            g_form.setValue('new_assingment_group',ba_group);
        }
    });
}

 

View solution in original post

3 REPLIES 3

Yashsvi
Kilo Sage

Hi @ronyates,

please check below script:

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
    if (isLoading || newValue === '') {
        return;
    }

    // Fetch the new assignment group value
    var newAssignmentGroup = g_form.getValue('assignment_group');

    // Set the new assignment group value to the variable field
    g_form.setValue('new_assignment_group', newAssignmentGroup);
}

Thank you, please make helpful if you accept the solution.

I try this but it still is not populating the field. 

I figured out why my initinal code was not working. The semi colon was missing from this line. g_form.getReference('assignment_group', function(user) {
if (user)

Should have been 

g_form.getReference('assignment_group', function(user) {
if (user);

function onChange(control, oldValue, newValue, isLoading) {
    if (isLoading || newValue == '') {
        return;
    }

    // Type appropriate comment here, and begin script below
    var ba_group = g_form.getValue('assignment_group');

	
    // Use getReference with callback
     g_form.getReference('assignment_group', function(user) {
        if (user); {
            g_form.setValue('new_assingment_group',ba_group);
        }
    });
}