Important Update: Archer Community Scheduled Maintenance on November 23–24 - New Community Launching Soon! Learn More..
2021-05-18 12:47 PM
Is there a global variable or method that returns the moduleId or LevelId when doing an AddNew content record?
With the custom object that I am creating, I would like to write the code generically so I dont have to hard code a fieldId. How can I get the fieldId generically when performing an AddNew? I typically hard code the FieldAlias and look up the fieldId but this is not possible unless the code has the ModuleId or LevelId.
2021-05-19 12:09 PM
Thanks for confirming.
Can you post the code that's calling the function?
I know it works in 6.9 SP2 so that's not the issue.
Advisory Consultant
2021-05-19 05:02 PM
David,
The function call is working. Validated by calling with another field name that happened to be a different type and it worked.
Seems to not work for Date fields. I tried adding another date field and put it on layout and neither one of the date fields is getting its FieldId returned when i pass their field names to the lookupFieldId function.
2021-05-20 04:35 PM
See how this version works Neil.
function lookupFieldId(fldName){
var goFindId = null;
try{
$('.FieldLabel').each(function(){
if(($(this).text().indexOf(fldName + ':') != -1) && ($(this).text().indexOf(fldName + ':') == 0)){
goFindId = $(this).find("span")[0].id;
return false;
}
});
} catch (err) {console.log(err)}
try {if (!goFindId) goFindId = $('.SectionLabel:findField("' + fldName + '")')[0].id;} catch (err) {}
try {if (!goFindId) goFindId = $('.SubSectionLabel:findField("' + fldName + '")')[0].id;} catch (err) {}
return goFindId ? $LM._layoutItems[goFindId.replace( /^\D+/g, '')].fieldId : 0;
}
$.expr[':'].findField = function(a, i, m) {
return $(a).text().replace(/[&\/\\#,+()$~%.'":*?<>{}]/g,'_').match("^" + m[3].replace(/[&\/\\#,+()$~%.'":*?<>{}]/g,'_') + "$");
};
Advisory Consultant
2021-05-24 12:14 PM
Thanks David that works.
2021-05-24 01:23 PM
Thanks for confirming Neil. Let me update my article with the latest code.
Advisory Consultant