Custom Function no longer working after updates

Custom Function no longer working after updates

We have recently been running through the 15x updates and are currently on build 15270. Somewhere in the updates at least one custom function of ours has stopped working as expected.

We have a series of functions that are meant to create a child request under certain circumstances. Now when that process is meant to kick off, there is instead an error produced that reads: 

"Error at line : 21, Value is empty and 'isText' function cannot be applied. Error in executing getDynamicFieldValue function. at line No.21\n"

That is what displays when attempting to test our emailNetwork_CreateChildRequest which is a custom function in the Request space. Line 21 in that function is the assignment of a pick field to a variable:

move_to_student_field = "$udf_fields,$udf_pick_4216";

When I use the View Request API in the API documentation to pull the request in question, I can see the picklist included in the request's udf fields.

  1. "udf_pick_4216": {
  2.     "name": "No",
  3.     "id": "1801"
  4. },

The other function that is mentioned is getDynamicFieldValue which is a global function. There is only one place in that function where isText is used. I will paste the entirety of getDynamicFieldValue below.

Any thoughts on what has changed and what will need to be updated to get this working again? This is all based on scripts that I had found previously in the community and support though I cannot find them again now.

  1. /* Used in child request creation to get field values.
    Function Name: getDynamicFieldValue
    Return Type: string
    API Name: getDynamicFieldValue
    Parameters:
        requestObj  Map
        fieldValue  string
        field   string
    */

    matches = findAllDynamicKeysMultiLevel(fieldValue);
    matches_len = matches.length();
    if(!matches.isNull()){
    for each match in matches{
        match_list = match.tolist("##SDP##");
        match_list_len = match_list.size();
        if (match_list_len == 1){
            field = match_list.get(0).replaceAll("$","",true);
            if ( fieldValue == match_list.get(0) && requestObj.containsKey(field) ){
                fieldValue = requestObj.get(field);
                if ("resolution" == field){
                    obj = requestObj.get(field);
                    obj.remove("resolution_attachments");
                    obj.remove("submitted_on");
                    obj.remove("submitted_by");
                    fieldValue = obj;
                    }
                else if ("requester" == field){
                    obj = requestObj.get(field);
                    obj.remove("is_vipuser");
                    obj.remove("department");
                    fieldValue = obj;
                    }
                }
                else {
                    dynamic_dollar_Val = match_list.get(0).replaceAll("$", "",true);
                    if (requestObj.containKey(dynamic_dollar_Val)){
                        dynamicVal = requestObj.get(dynamic_dollar_Val);
                        fieldValue = fieldValue.replaceAll(match_list.get(0), dynamicVal,"true");
                    }
                }
            }
        else if (match_list_len > 1){
            is_obj_exists = true;
            match_list2 = match_list;
            match_list2.remove(match_list2.size()-1);
            z=0;
            for each match_2 in match_list2{
                match_str = match_list.get(z).replaceAll("$", "",true);
                if (z == 0){
                    if (requestObj.containKey(match_str)){
                        hierachy_obj = requestObj.get(match_str);
                        }
                    else{
                        is_obj_exists = false;
                        }
                    }
                else{
                    if (hierachy_obj.containKey(match_str)){
                        hierachy_obj = hierachy_obj.get(match_str);
                        }
                    else{
                        is_obj_exists = false;
                        }
                    }
                if(is_obj_exists == false){
                    break;
                    }
                z=z+1;
                }
            if(is_obj_exists == true){
                last_str = match_list.get(match_list_len-1);
                last_str = last_str.replaceAll("$", "",true);
                if(!("null".equalsIgnoreCase(hierachy_obj)) && hierachy_obj.containsKey(last_str)) {
                    dynamicVal = hierachy_obj.get(last_str);
                    if(dynamicVal.isText() || dynamicVal.isNumber()){
                        match_dynamic_str = match.replaceAll('##SDP##',',',"true");
                        fieldValue = fieldValue.replaceAll(match_dynamic_str,dynamicVal,"true");
                        }  
                    else{
                        fieldValue = dynamicVal;
                        }
                    }
                }
            }
        }
    }
    return fieldValue;
UPDATE: I realized with further testing that "line 21" actually only counts after the comments I have at the top of that function. So the actual line 21 is:

is_software_required_field_val = getDynamicFieldValue(requestObj,is_software_required_field,"udf_fields");

The is_software_required_field variable referenced here is set above that as:
is_shared_drive_required_field = "$udf_fields,$udf_sline_4501";

So this does not appear to be relevant to pick fields after all. When I look at the request in question, udf_sline_4501 is indeed null. So it seems that getDynamicFieldValue is just not handling null values well.

                        New to ADSelfService Plus?