0 votes


I try to avoid the modification of a main relation using workflow and I get troubles:
With the code below when I try to modify or delete relation by edit relation on contact THIS WORK
but when I edit contact and change/delete on the right side the company link nothing is trigger and the link is change ???

How can I avoid the fact that the relation can be change on edit contact ?

Best regards.

here is my code:

function BeforeCommitContComp(EditHandle, Inserted) {
        ContCompDataSet = EfficyAPI.GetMasterDataSet(EditHandle, 0),
        ContKey = ContCompDataSet.FieldByName('K_CONTACT').AsFloat,
        ContMain = ContCompDataSet.FieldByName('MAIN').AsString;
    if(IsMainComp(ContKey) && ContMain == '0') {
        log("Vous ne pouvez pas changer la relation entre ce contact et une société mère ! k-contact=" + ContKey);
        throw new Error("You can't change relation between this contact and main company!");

function OnBeforeDeleteContComp(Key, DetailKey) {
    if(IsMainComp(Key)) {
        log("Vous ne pouvez pas effacer le lien avec une société mère ! k_contact=" + Key);
        throw new Error("You can't delete relation with a main company!");
asked in Partners by (182 points)

1 Answer

+1 vote
Best answer


In the commit of the contact, you can check if the detail Comp has changed and if the user does not has permissions. If not, throw an exception.

function BeforeCommitCont(editCont, inserted) {
    if (Efficy.detailModified(editCont, ntComp) && !Efficy.isCurrentUserInGroup(Efficy.getUserId("EFF_ADMINS")) {
        throw Error("You are not allowed to modify the company relation!");
answered by (7.4k points)
selected by
Welcome to Efficy Overflow, where you can ask questions and receive answers from other members of the community.
1,249 questions
1,521 answers
328 users