Empty field on catalogue item appearing as NULL on requested item

matthew_hughes
Kilo Sage

I've got a catalogue item that allows a user to not select a certain field and they can leave this empty:

matthew_hughes_0-1735916652136.png

From the screenshot, the user can leave the New Lab Level/Platform Child field empty. However, when a user submits their request, it appears as NULL in the requested item rather than showing as empty:

matthew_hughes_1-1735916730125.png

 

I'm using a multi row variable set to get my results.  The following client scripts apply to the New Platform and New Lab Level/Platform Child fields:

matthew_hughes_2-1735916915878.png

 

function onChange(control, oldValue, newValue, isLoading) {
    //If form is loading, do nothing
    if (isLoading) {
        return;

    //If the list of Business Applications to update is cleared, clear the Multi Row variable set
    } else {
        //if(newValue == null){
            g_form.clearValue('new_lab_department');
        //}
        var gr = new GlideAjax('LBGGetApplicationDetails');
        gr.addParam('sysparm_name', 'existing_app_srvc');
        gr.addParam('sysparam_ci_sysid', g_form.getValue('business_applications_to_update'));
        //gr.addParam('sysparam_u_business_owning_division', current_owning_platform);
        if(newValue != null){
            gr.addParam('sysparm_platform', g_form.getDisplayValue('new_platform'));
        }
        else{
            gr.addParam('sysparm_platform', "");
        }
        if(g_form.getValue('new_lab')!=null){
            gr.addParam('sysparm_lab', g_form.getDisplayValue('new_lab_department'));
        }
        else{
            gr.addParam('sysparm_lab', "");
        }
        gr.getXML(parseScript);
    }
}

function parseScript(response) {
    var answer = response.responseXML.documentElement.getAttribute("answer");
    var arr = JSON.parse(answer);
    if (arr.length > 0) {
        g_form.setValue("selected_business_applications", answer);
    } else if (arr.length == 0) {
        g_form.setValue("selected_business_applications", []);
    }

}


matthew_hughes_3-1735916962568.png
function onChange(control, oldValue, newValue, isLoading) {
    //If form is loading, do nothing
    if (isLoading) {
        return;

    //If the list of Business Applications to update is cleared, clear the Multi Row variable set
    } else {
        var gr = new GlideAjax('LBGGetApplicationDetails');
        gr.addParam('sysparm_name', 'existing_app_srvc');
        gr.addParam('sysparam_ci_sysid', g_form.getValue('business_applications_to_update'));
        //gr.addParam('sysparam_u_business_owning_division', current_owning_platform);
        if(newValue != null){
            gr.addParam('sysparm_lab', g_form.getDisplayValue('new_lab_department'));

        }
        else{
            gr.addParam('sysparm_lab', "");
        }
        if(g_form.getValue('new_platform')!=null){
            gr.addParam('sysparm_platform', g_form.getDisplayValue('new_platform'));
        }
        else{
            gr.addParam('sysparm_platform', "");
        }
        gr.getXML(parseScript);
    }
}

function parseScript(response) {
    var answer = response.responseXML.documentElement.getAttribute("answer");
    var arr = JSON.parse(answer);
    if (arr.length > 0) {
        g_form.setValue("selected_business_applications", answer);
    } else if (arr.length == 0) {
        g_form.setValue("selected_business_applications", []);
    }

}


matthew_hughes_4-1735917007839.png

 

function onChange(control, oldValue, newValue, isLoading) {
    //If form is loading, do nothing
    if (isLoading) {
        return;

    //If the list of Business Applications to update is cleared, clear the Multi Row variable set
    } else if (newValue == '') {
        g_form.setValue('selected_business_applications', []);
   
    //Each time a Business Application is added, add a row for each Business Application with the other variables
    } else {
        var gr = new GlideAjax('LBGGetApplicationDetails');
        gr.addParam('sysparm_name', 'existing_app_srvc');
        gr.addParam('sysparam_ci_sysid', newValue);
        //gr.addParam('sysparam_u_business_owning_division', current_owning_platform);
        if(g_form.getValue('new_platform') != null){
            gr.addParam('sysparm_platform', g_form.getDisplayValue('new_platform'));
        }
        else{
            gr.addParam('sysparm_platform', "");
        }
        if(g_form.getValue('new_lab_department') != null){
            gr.addParam('sysparm_lab', g_form.getDisplayValue('new_lab_department'));
        }
        else{
            gr.addParam('sysparm_lab', "");
        }
        gr.getXML(parseScript);
    }
}

function parseScript(response) {
    var answer = response.responseXML.documentElement.getAttribute("answer");
    var arr = JSON.parse(answer);
    if (arr.length > 0) {
        g_form.setValue("selected_business_applications", answer);
    } else if (arr.length == 0) {
        g_form.setValue("selected_business_applications", []);
    }

}


 

Does anyone know what I need to do to show New Lab Level/Platform Child field as an empty value on my requested item rather than null

8 REPLIES 8

Ahmmed Ali
Mega Sage

Hello @matthew_hughes 

 

Since the MRVS values are handled as JSON string, it shows empty values as null sometimes in processing. I had faced similar issue earlier, I had workaround to clear the value in field after the form is submitted via server script. You can query sc_multi_row_question_answer table and update the record with the question.

 

Thank you,

Ali

 

If I could help you with your Query then, please hit the Thumb Icon and mark my answer as Correct!!

Thank you,
Ali

Hi @Ahmmed Ali  Did you do that as a onSubmit client script?

Hello @matthew_hughes 

 

No, if you clear it on onSubmit, it will still add null in server processing. I had done that in ASYNC BR on the target table (as mine was record producer, if yours is catalog item, you can do the same in workflow).

 

Thank you,

Ali

 

If I could help you with your Query then, please hit the Thumb Icon and mark my answer as Correct!!

Thank you,
Ali

Hi @Ahmmed Ali  I'm using flow designer for my catalogue item. How would I apply it to my flow?