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

@hmealstrom can you post your custom object?

 Advisory Consultant

Thanks for your answer @DavidPetty  Here is my code

 

´´´

<script type="text/javascript">


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);
}
}
}

Sys.Application.add_load(function()
{
var vlField = 26923; // Values List Field
var deleteXrefFields = [27275]; // Id of Cross-Reference Field


var selectedValue = $CM.getFieldValue(vlField);
var idVltoclear= ['88628:0']; // Value Id of Values List Field


if (selectedValue[0] == idVltoclear[0]) {
console.log("The value is selected 88628:0"); // Flag to see output in console terminal
setXrefFieldValues(deleteXrefFields[0], []);


}


console.log(selectedValue)
});



</script>



´´´

 

 

 

I have two errors:

  • When I enter the record. It is stuck in the loading screen and the console.log says
Record.aspx?id=32647…3ef773399488e7e:620 Uncaught TypeError: Cannot read properties of null (reading '0')
    at Array.<anonymous> (Record.aspx?id=32647…773399488e7e:620:28)
    at ScriptResource.axd?d…&t=511fa37d:5:51370
    at Sys._Application.raiseLoad (ScriptResource.axd?d…&t=511fa37d:5:70677)
    at Sys._Application.initialize (ScriptResource.axd?d…&t=511fa37d:5:70327)
    at b (ScriptResource.axd?d…&t=511fa37d:5:71512)
    at HTMLDocument.a (ScriptResource.axd?d…&t=511fa37d:5:71786)
(anonymous)	@	Record.aspx?id=32647…3ef773399488e7e:620
(anonymous)	@	ScriptResource.axd?d…C22VM1&t=511fa37d:5
raiseLoad	@	ScriptResource.axd?d…C22VM1&t=511fa37d:5
initialize	@	ScriptResource.axd?d…C22VM1&t=511fa37d:5
b	@	ScriptResource.axd?d…C22VM1&t=511fa37d:5
a	@	ScriptResource.axd?d…C22VM1&t=511fa37d:5

 

  • And when i manage to bypass the loading screen. The code works but in the console log the following message appears to be repeating indefinitely 
VM8663:1 Uncaught SyntaxError: Identifier 'windowFields' has already been declared
    at Sys._ScriptLoader._loadScriptsInternal (ScriptResource.axd?d…1&t=511fa37d:5:4736)
    at Sys._ScriptLoader._loadScriptsInternal (ScriptResource.axd?d…1&t=511fa37d:5:4794)
    at Sys._ScriptLoader._loadScriptsInternal (ScriptResource.axd?d…1&t=511fa37d:5:4794)
    at Sys._ScriptLoader._loadScriptsInternal (ScriptResource.axd?d…1&t=511fa37d:5:4794)
    at Sys._ScriptLoader._loadScriptsInternal (ScriptResource.axd?d…1&t=511fa37d:5:4794)
    at Sys._ScriptLoader._loadScriptsInternal (ScriptResource.axd?d…1&t=511fa37d:5:4794)
    at Sys._ScriptLoader._loadScriptsInternal (ScriptResource.axd?d…1&t=511fa37d:5:4794)
    at Sys._ScriptLoader._loadScriptsInternal (ScriptResource.axd?d…1&t=511fa37d:5:4794)
    at Sys._ScriptLoader._loadScriptsInternal (ScriptResource.axd?d…1&t=511fa37d:5:4794)
    at Sys._ScriptLoader._loadScriptsInternal (ScriptResource.axd?d…1&t=511fa37d:5:4794)
_loadScriptsInternal	@	ScriptResource.axd?d…VZClA1&t=511fa37d:5
_loadScriptsInternal	@	ScriptResource.axd?d…VZClA1&t=511fa37d:5
_loadScriptsInternal	@	ScriptResource.axd?d…VZClA1&t=511fa37d:5
_loadScriptsInternal	@	ScriptResource.axd?d…VZClA1&t=511fa37d:5
_loadScriptsInternal	@	ScriptResource.axd?d…VZClA1&t=511fa37d:5
_loadScriptsInternal	@	ScriptResource.axd?d…VZClA1&t=511fa37d:5
_loadScriptsInternal	@	ScriptResource.axd?d…VZClA1&t=511fa37d:5
_loadScriptsInternal	@	ScriptResource.axd?d…VZClA1&t=511fa37d:5
_loadScriptsInternal	@	ScriptResource.axd?d…VZClA1&t=511fa37d:5
_loadScriptsInternal	@	ScriptResource.axd?d…VZClA1&t=511fa37d:5
_loadScriptsInternal	@	ScriptResource.axd?d…VZClA1&t=511fa37d:5
_loadScriptsInternal	@	ScriptResource.axd?d…VZClA1&t=511fa37d:5
_loadScriptsInternal	@	ScriptResource.axd?d…VZClA1&t=511fa37d:5
_loadScriptsInternal	@	ScriptResource.axd?d…VZClA1&t=511fa37d:5
_loadScriptsInternal	@	ScriptResource.axd?d…VZClA1&t=511fa37d:5
_nextSession	@	ScriptResource.axd?d…VZClA1&t=511fa37d:5
_loadScriptsInternal	@	ScriptResource.axd?d…VZClA1&t=511fa37d:5
_nextSession	@	ScriptResource.axd?d…VZClA1&t=511fa37d:5
loadScripts	@	ScriptResource.axd?d…VZClA1&t=511fa37d:5
_onFormSubmitCompleted	@	ScriptResource.axd?d…VZClA1&t=511fa37d:5
(anonymous)	@	ScriptResource.axd?d…C22VM1&t=511fa37d:5
(anonymous)	@	ScriptResource.axd?d…C22VM1&t=511fa37d:5
completed	@	ScriptResource.axd?d…C22VM1&t=511fa37d:5
_onReadyStateChange	@	ScriptResource.axd?d…C22VM1&t=511fa37d:5
XMLHttpRequest.send (async)		
executeRequest	@	ScriptResource.axd?d…C22VM1&t=511fa37d:5
executeRequest	@	ScriptResource.axd?d…C22VM1&t=511fa37d:5
invoke	@	ScriptResource.axd?d…C22VM1&t=511fa37d:5
_onFormSubmit	@	ScriptResource.axd?d…VZClA1&t=511fa37d:5
_doPostBack	@	ScriptResource.axd?d…VZClA1&t=511fa37d:5
(anonymous)	@	ScriptResource.axd?d…C22VM1&t=511fa37d:5
setLookedUpRecords	@	ScriptResource.axd?d…SnNE1&t=2b3b2ab3:85
setXrefFieldValues	@	Record.aspx?id=32647…ight=1011%2c711:648
(anonymous)	@	Record.aspx?id=32647…ight=1011%2c711:675
(anonymous)	@	ScriptResource.axd?d…C22VM1&t=511fa37d:5
raiseLoad	@	ScriptResource.axd?d…C22VM1&t=511fa37d:5
initialize	@	ScriptResource.axd?d…C22VM1&t=511fa37d:5
b	@	ScriptResource.axd?d…C22VM1&t=511fa37d:5
a	@	ScriptResource.axd?d…C22VM1&t=511fa37d:5

Hi @DavidPetty  Could you provide any insight to my code? I very appreciate it. Thanks