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-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-18 12:52 PM
Neil, to get field ids you can use this custom object, The Horror's of Moving Custom Objects from One Environment to Another - RSA Link - 569029
Advisory Consultant
2021-05-18 01:08 PM
When creating a new record, the URL parameters will include moduleId. For example, the module id is 545 in the following: RSAarcher/GenericContent/Record.aspx?id=0&moduleId=545. With that, you can make API calls to get names, fields, etc.
2021-05-18 04:11 PM
Hi David,
I couldn't get the lookupFieldId to work in 6.8 P4 HF2.
2021-05-18 04:12 PM
Thanks Jeff... I was able to parse window.location.search for the moduleId.
2021-05-18 04:13 PM
Neil, is the field on layout?
Mine posting the code?
Advisory Consultant
2021-05-18 05:29 PM
Jeff,
It appears that I cannot get this work since the levelId is not available when doing an AddNew With fields with the same name on each level, then how do get the fieldId when I don't know the level?
2021-05-18 05:32 PM
Hi David,
I put the lookupFieldId function in the Sys.Application.add_load(function.
Also, tried with the lookupFieldId function outside of Sys.Application.add_load(function. but called it from within Sys.Application.add_load.
2021-05-19 08:44 AM
Are the fields on the layout and in the application the custom object is running in?
Advisory Consultant
2021-05-19 12:03 PM
David,
The field that I want the FieldId for is on the layout of the application my custom object is running in.
The lookupFieldId function returns 0.