0 votes


I create a new entity named Trai (key 50) and with a servercript I try to create a relation between this entity and a contact. I got an error when I try to link this contact by script but work if I use the right side of the edit form contacts (add link to a contact). To debug I run this script from the scheduler and got this message

Error: WKFL-2142 Error while executing script "bentest" at line 1020 char 4. (File "C:\inetpub\wwwroot\11.0\customs\xxx\serverscripts\NLservertest.js" line 25)
Message: "Incorrect Detail for Edit Context"

function bentest() {
    var editHandle = Efficy.openEditContext(ntCont, 67067, false);
            var ds = Efficy.getMasterDataSet(editHandle, 0);
            Efficy.insertDetail2(editHandle, 50, 64, false);
            Efficy.commitChanges(editHandle, true);
        } finally {

line 25 is the insertDetail2 line.

asked in Partners by (182 points)
edited by

1 Answer

+1 vote

In the user interface, you are in the edit of your Trai entity because you insert a detail using "Add link to contact".

In the serverscript, you are trying the opposite. Editing the contact and inserting Trai as a detail.

Code like you are working interface. This is a golden tip for every scripting in Efficy, btw

  1. Open the edit context of Trai
  2. Insert a Cont detail
  3. Commit and close context


answered by (7.4k points)
Or use the consult method

Efficy.addLink2(entity, detail, key, detailKey, ignoreExisting)
Then you risk having no main contact on the Trai.
Yes this is something I never understood... why in standard we cannot specify that the link, we try to create from consult, is the main link.... may be something to propose to R&D for improvement?
There is no single place in the user interface where you can do an addLink2 if the detail is also available in edit. It doens't make sense.

Edit: if you for instance don't have modify permissions on a project or opportunity, you can't add a contact or company through the user interface. That's a good reason.

No, it will not be an improvement.
I don't completely agree, for instance if I am on a company and link a contact, the Edit relation windows appear (from the user interface) because you cannot add a contact from the company edit window.

If I do want to add a contact to a company in a serverscript, I will have to open an edit context on the relation to link the company to the contact.

From my point of view it would have been much more easier to be able to specify if the contact I want to add via AddLink2 is the main contact or not (if I only have to link without changing anything on the relation)
Welcome to Efficy Overflow, where you can ask questions and receive answers from other members of the community.
1,248 questions
1,518 answers
328 users