heckytect
07/12/2017, 2:11 AMfunction nlapiGetCurrentLineItemValue(type,fldnam)
{
nsapiAssertTrue(!isSubrecordField(type, fldnam), 'SSS_INVALID_OPERATION_USING_SUBRECORD_FIELD');
if (hasEncodedField(type, fldnam))
{
if ( isEditMachine(type) )
return getFormValue(getFormElement( document.forms[type.toLowerCase()+'_form'], getFieldName(fldnam) ));
else
{
var linenum = nlapiGetCurrentLineItemIndex(type);
if ( getEncodedFieldType(type, fldnam) == "radio" )
return getRadioValue( getFormElement( document.forms[type.toLowerCase()+'_form'], getFieldName(fldnam) ) ) == linenum ? 'T' : 'F';
if (fldnam.indexOf('_display') > 0)
{ // insert the line number into the display field name if it is a popup select or popup multiselect
var hiddenFldName = fldnam.replace('_display','') + linenum;
var hiddenFld = getFormElement(document.forms[type.toLowerCase()+'_form'],hiddenFldName);
if (isPopupSelect(hiddenFld) || isPopupMultiSelect(hiddenFld))
fldnam = hiddenFldName.toLowerCase() + '_display';
else
fldnam = getFieldName(fldnam)+linenum;
}
else
fldnam = getFieldName(fldnam)+linenum;
return getFormValue(getFormElement( document.forms[type.toLowerCase()+'_form'], fldnam));
}
}
else if (hasEncodedField(type, "options"))
{
if (optwin != null)
return optwin.getFormValue(optwin.document.forms[0].elements[getFieldName(fldnam)]);
else
return getnamevaluelistvalue(document.forms[type.toLowerCase()+'_form'].options.value,fldnam);
}
else
{
if (typeof fieldtosubrecordmap != 'undefined')
{
var subrecordname = fieldtosubrecordmap[type+'_'+fldnam];
if (subrecordname != null && subrecordname.length> 0 )
{
var subrecordfieldname = fieldtosubrecordfieldmap[type+'_'+fldnam+'_'+subrecordname];
if ( subrecordfieldname != null && subrecordfieldname.length> 0)
{
var subrecord = nlapiLoadCurrentLineItemSubrecord(type, subrecordname,false);
if (subrecord)
{
return subrecord.getFieldValue(subrecordfieldname);
}
}
}
}
}
return null;
}