1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

  2. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

Trigger - Unique Field Combination Not Working as expected

Discussão em 'PSDN - Forum' iniciado por IramK, Abril 27, 2015.

  1. IramK

    IramK Guest

    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.

    Continue reading...

Compartilhe esta Página