Important Update: Community URLs redirect issues are partially resolved. Learn More. .

cancel
Showing results for 
Search instead for 
Did you mean: 

How to populate a cross reference field using a Custom Object

AlexanderHatfie
Contributor II

I'm currently storing a variable that contains the Tracking ID from another application that has a cross reference into the app that I want to make this Custom Object. I'm not sure where to begin to be able to perform a lookup to reference that Tracking ID to the record in the cross referenced app. Would anyone be able to point me in the right direction?

12 REPLIES 12

Ilya_Khen
Champion III

I'm trying to avoid using API calls if possible. In previous Custom Objects I've been able to insert text into various field types or change values lists, I'm looking to see if something similar is possible for Cross Reference fields.

Alexander,

 

I do not think you can insert any date via pure JS into CR. Because JS is operating only with the end user content in the browser. While data are stored in the backend.

What you did with standard fields like Text or VL, you changed the DOM objects, but it got saved ONLY after you pressed Save.

CR is a bit different, as it is presented in form of a grid, but not actual data representation.

 

However, I might got your request wrongly.

I'll drop this little nugget here 

function setXrefFieldValues(fieldId,values){
     field = $CM._fields[fieldId].clientId;
     ArcherTech.UI.ReferenceField.CurrentLookupField = $find(field);
     var currentField=ArcherTech.UI.ReferenceField.CurrentLookupField;

     if(currentField) {
          currentField.setLookedUpRecords(values);
          if (currentField.get_isInDdeCondition() && Sys.WebForms.PageRequestManager.getInstance().get_isInAsyncPostBack()) {
               var endRequestHandler = function () {
                    ArcherTech.UI.ReferenceField.UpdateCurrentField(values);
                    Sys.WebForms.PageRequestManager.getInstance().remove_endRequest(endRequestHandler);
               };
               Sys.WebForms.PageRequestManager.getInstance().add_endRequest(endRequestHandler);
          } else {
               ArcherTech.UI.ReferenceField.UpdateCurrentField(values);
          }
     }
}‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

 

Call the function like so:

setXrefFieldValues(1234, [5678,9012,3456]);‍‍‍‍‍

 

 Advisory Consultant

Very nice, David

I wish I would know all internal functions  You need to write a book

Is there any documentation for the Archer JS Library or do customers have to rely on the community and time to hack away at it?

Hi Dave,

I tried to use the above function to clear multiply XREF fields in my custom object code 

based on a selected radio button value, but it seems all the XREF fields on the layout get cleared no matter what I select. I attached my code example. ANY Assistance would be appreciated.
 
Thanks,
Frank

 

@Fsantana the function will only clear the cross-reference fields supplied to the function.  Add a console.log() right before you make the call to see what values you're sending to the function and see what's going on.

 Advisory Consultant

hmealstrom
Contributor II

Hi, I am also trying to use XREF function to clear out a Cross-reference field based on a selected value of a valuelist field. But I am no getting the correct response. The custom object seems to do nothing.  What are the input values that I shoul specifiy ?