Hello,
I am trying to use an unique field combination trigger that is not working as it was back in version 3.0.5.0. Below is the code for the unique field combination formula:
if("{!R58328.id}" !== "0") { // First return the related Opp. Contact records for that ID var returnedIDs = rbv_api.getRelatedIds("R58328", {!R58328.id}); var result = false; // Then get the Contact ID's for all those Opp Contacts for(var i = 0; i < returnedIDs.length; i++) { var value = rbv_api.getRelatedFields("R58300", returnedIDs[ i ], "id"); var returnedContactID = value[0];
// Compare this value with the actual field value and see if there is something already present in the list of Opp contact records if("{!contactId}" != returnedContactID) { result = false; } else { result = true; break; } } return result; }
So basically the above code first gets related IDs for a parent Object Record : lets say: 12345, 23456, 34567 (related records) and then I search for the "id" value for a related object called using the getRelatedFields function after which I'm comparing that id with other records contact "id" to make sure there aren't any more available. If there is: then I return true and throw an error.
Hi IramK,
Can I have a test XML or maybe generic objects representing the relationships to R58328 and R58300, this would help me build the test app to test the functionality.
Also, since this is a Unique Field combination trigger, what are the fields in "Selected Fields" area?
Thank you.
Regards,
Orchid
Hello [mention:e6fb884e9c7b45a2a638966c06dc0941:e9ed411860ed4f2ba0265705b8793d05] ,
I just recreated the same trigger without the above mentioned code in the new version i.e. 3.2.0.0 and it started working without any issues. Its as though the migrated triggers from the old version 3.0.5.0 don't seem to work as they did in the older version. Recreating the same trigger in the new release seems to get rid of the issue.
Good to know, so this seems to be working fine in the latest version.
Yes creating a similar trigger with the same properties and deleting the migrated trigger does work in the latest version but I'm worried that the migration of apps from version 3.0.5.0 to 3.2.0.0 did not get the triggers across properly. My other triggers were failing as well and I'm guessing its too do with the same thing i.e. Migration. Could you possibly check this whether migrating an app with a trigger like the one I mentioned above works in the latest release as well as expected?
Have you tried in 3.0.5 to remove the code above? I saw at the above comment that in 3.2.0.0 you remove the mentioned code and starts working fine. I'm thinking if the conditions in the codes returned false then checking of unique field values will be ignored.
Regards,
Orchid
I don't know if this is related to the issue, but the following items jumped out at me:
if("{!R58328.id}" !== "0") <------------------ I would suggest testing for > 0 (I have seen a -1 value for this test)
{
// First return the related Opp. Contact records for that ID
var returnedIDs = rbv_api.getRelatedIds("R58328", {!R58328.id}); <---- This logic could end up selecting the wrong Id
In Parent/Child relationships, the parent reference for Object scripts is defined as {!Pobjectintegrationname#id}. Otherwise, how do you know which Object is being selected in the relationship if its a multi-level hierarchy?
Thanks cohenzive for sharing, in conditions I do usually use if({!R123456#id} > 0) ---> it is ok to use this even multiple-value lookups
-Orkid