/* 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;