Important Update: Some Community URL Redirects are Under Maintenance. Learn More. .

cancel
Showing results for 
Search instead for 
Did you mean: 

Hiding the 'Add New' Link for Cross-Reference Fields not working for Grid type

Archerwizz2022
Contributor III

Thank you @DavidPetty for this code, it's really helpful.

When I tried using it, it only worked for Single Column cross reference, but not for the Grid. 

The lookupFieldId function couldn't find the id for the Grid cross reference.

Do you have any updated version or insights?

Thank you

https://www.archerirm.community/t5/archer-custom-objects/hiding-the-add-new-link-for-cross-reference-fields/ta-p/632035

 

1 ACCEPTED SOLUTION

Accepted Solutions

That's not the line that looks for cross-reference/sub-form fields.  This is the line,
try {if (!goFindId) goFindId = $('.SectionLabel:findField("' + fldName + '")')[0].id;} catch (err) {}

Is there no space before or after the field name in the Application Builder or the custom object code?

Same code and it's hiding for me,

DavidPetty_0-1649262469812.png

 

var crossReferenceToHideAddNew = getFieldId(['Select First Stakeholder', 'Control Standards']);

 

 Advisory Consultant

View solution in original post

8 REPLIES 8

DavidPetty
Archer Employee
Archer Employee

@Archerwizz2022 is the cross-reference field set as a grid in its own section or embedded in an existing section?

 Advisory Consultant

Multiple cross references are placed in one section, some are grid and others are single column.

Thanks, which version of Archer?

 Advisory Consultant

Version 6.10 P1 HF2

DavidPetty
Archer Employee
Archer Employee

@Archerwizz2022, I just tested the custom object with a few cross-reference fields inside a section and had no issues hiding the Add New link.

DavidPetty_0-1649252791231.png

If you change the debugging variable from false to true, what's being outputted in the browser developer tools console?

 Advisory Consultant

As you can see, the first Grid cross reference still has the "Add New", while the single column cross reference had the "Add" link disappeared.

After reviewing the code, I thought it could be because of the colon you added in the 

if($(this).text().indexOf(fldName + ':') != -1){

Which I removed, since the grid cross reference doesn't have a colon, but still, it didn't work.

Also, I noticed that the label for the grid cross reference is an image, and not a text. While the single column cross reference, the label is a text. Could that be the issue.

Thank you

 

 

debug1.pngdebug2.png

 

 

That's not the line that looks for cross-reference/sub-form fields.  This is the line,
try {if (!goFindId) goFindId = $('.SectionLabel:findField("' + fldName + '")')[0].id;} catch (err) {}

Is there no space before or after the field name in the Application Builder or the custom object code?

Same code and it's hiding for me,

DavidPetty_0-1649262469812.png

 

var crossReferenceToHideAddNew = getFieldId(['Select First Stakeholder', 'Control Standards']);

 

 Advisory Consultant

Archerwizz2022
Contributor III

It's finally working. I guess you know your code better. The cross reference field name had a space.