Adding item to relationship tab via script

Adding item to relationship tab via script

Johnny.Matthys
Participant Participant
68 Views
0 Replies
Message 1 of 1

Adding item to relationship tab via script

Johnny.Matthys
Participant
Participant

I have the following script that is resulting in the following error.  I can't figure out what I'm doing wrong as from what I can tell I'm following the right format.  Any suggestions would be appreciated. 

// Single field
var doc = item.DECLARATION_OF_CONFORMITY;
if (doc !== null) {
item.relationships.addRelated(doc, "Cross-reference", "Uni-Directional", "");
}


// Grid field
if (item.grid.length > 0) {
for (var x = 0; x < item.grid.length; x++) {
var ctr = item.grid[x].COMPLIANCE_TEST_REPORT;
if (ctr !== null) {
item.relationships.addRelated(ctr, "Cross-reference", "Uni-Directional", "");
}
}
}

 

This results in the following error.

[Compliance Dossier Relationship update (line 4, col 0)] org.mozilla.javascript.WrappedException: Wrapped com.dms.scripting.exceptions.ScriptFunctionException: Cannot add a new relationship based on "[PartWrapper[Part[103542]{ DECLARATION_OF_COMPLIANCE_NUMBER=null, APV_LINK=null, IFIXIT_ITEM_CODE=null, SKU=null, DESCRIPTION=null, BRAND=null, PLACE_MANUFACTURED=null, ASSOCIATED_MARKET=null, DECLARATION_REQUIREMENTS=null, REGISTRATIONREPORTING_REQUIREMENTS=null, CUSTOMER_DISCLOSURE_REQUIREMENTS=null, DECLARATION_CREATION_DATE=null, TEST_DATE=null, TEST_FINISH_DATE=null, REPORT_NUMBER=null, TESTING_AGENCY_NAME=null, TESTING_AGENCY_MAILING_ADDRESS=null, TESTING_AGENCY_PHONE_NUMBER=null, RESPONSIBLE_PERSON=null, RESPONSIBLE_PERSON_TITLE=null, RESPONSIBLE_PERSON_ADDRESS=null, SVHC_CONTENT_01_WW=null, SVHC_CONTENT_LESS_01_WW=null, COMPLIES_WITH_ANNEX_XVII_LIMIT=null, SCIP_REGISTRATION_REQUIRED=null, SCIP_NUMBER=null, BATTERY_RATING=null, BATTERY_CLASSIFICATION=null, BATCH_NUMBER=null, NOTIFIED_BODY=null, DIGIT_NOTIFIED_BODY_NUMBER=null, REF_OF_CERTIFICATE_OF_NOTIFIED_BODY=null }]]" (Compliance Dossier Relationship update#4)

0 Likes
69 Views
0 Replies
Replies (0)