0 votes

Dear All,

I am trying to search how the relation is created when you click on the + button in the consult grid of an entity. It bring the search window, but when you click on the Add new button in the search button ... then I am confused. Here is what I understand :

1- when I click on the + button in the consult, it open the search window with the parameter
"action=CreateRelation(1009%3BProp%3B1186)" ... which is used to add the key of the selected entity in this function if I click directly in the search result. Which is ok and I have my hand on it if I want.

2- if I click on the Add new button in the search button, the parameter is transfer to the Edit windows of the new Entity we want to create "action=CreateRelation(1009%3BProp%3B1186)"
But when I clicked on "OK" or "APPLY", the new entity is created and I don't know where Efficy has created the linked using the information in the action passed in the URL ...

The issue is that when we do that the new entity is becoming the parent of the entity where we click on the create relation button, but normally it should be the child.

And I don't know where this happened.

PS : I suspect that this is handled in the Efficy.dll ... but I would like a confirmation of it.

Best Regards,
Stéphane

asked in WorkFlow / Serverscript by (1.9k points)

3 Answers

+1 vote
Best answer

Digging a bit deeper in this I found the problem (and a simple solution).

The problem is that you have added the PropProp table to the PropEdit EntityView - which means that you intend to edit the PropProp relation within the edit window of a Property.
In that case the relation is instantly created inside the edit window of the new Property (but is created in the wrong order), and CreateRelation is never called.

The TableViews of PropEdit are currently as follows:

Prop;Prop_User=User;Prop_Comp=Comp;Prop_Cont=Cont;Prop_Proj=Proj;Prop_Oppo=Oppo;Prop_Acti=Acti;Prop_Prop=Prop;

The solution is to simply remove the last item (Prop_Prop=Prop) from the list.

answered by (1.2k points)
selected by
Really good to know that PropEdit EntityView has an impact on the Create Relation in Edit context, I tested it by removing the Prop_Prop=Prop; and now it is working.

Before removing it I just checked that I didn't have any InsetDetail2 used to link property into property edit windows. Since it was not the case I did remove the configuration in PropEdit EntityView.

Thank you very much Robert
+1 vote

Hi Stéphane.

Until Efficy 10, the action argument of the URL is just encoded JavaScript that will be executed when you have committed your edit window. The provided JavaScript will be decoded and added to the response as global javascript in a <script> block.

There is nothing hardcoded inside Efficy.dll or any serverside magic that makes the relation for you. If for some reason the CreateRelation function client side is not executed, your relation will not be made.

Note that for Efficy 11, the action is no longer encoded JavaScript, but uses predefined verbs instead, to overcome the XSS vulnerability.

Example:

When you commit the following edit context
edit?page=edit/Edit.htm&entity=Cont&action=CreateRelation(1006%3BCont%3B2)

efficy.dll returns the followin response. The content of the action is inserted. You can pause your Chrome debugger when the window closes and take a look at the response.

<!doctype html>
<html>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<head>
</head>
<body>
<script src ="../efficy/js/config/require.config.js" ></script>
<script src ="../efficy/../lib/js/vendor/require.js" ></script>
<script src ="../efficy/scripts/Base.js" ></script>
<script src ="../efficy/scripts/Efficy.js" ></script>
<script src ="../customs/Dev_10/Custom.js" ></script>
<script>
Relocating = true
CreateRelation('1006','Cont','2','Cont',7)
</script>
</body>
</html>

When in the search result, you select the contact, the anchor contains an updated action. This is the result of the Grid tag: <#A=$FIELD$>

<a href="javascript:CreateRelation('1006','Cont','2','Cont',7)">Pauwels Kristof</a>

This explains the extending of the action from the URL with the selected record.

answered by (7.4k points)
edited by
Sorry Kristof, I think I was too quick to click on the Best Answer ...

There is still something I cannot find, is the code where the Script block is added, I can not point out where this is built
I edited my original answer to include the sample.
Does it means the DLL is adding "'Cont',7" into the function or is it concatenated somewhere in a script ?
The action is updated because of the usage of the A grid tag, comes from Action
I am so sorry, but this is true if I select a contact in the search window, but this is not true if I create a contact from the search window
Well, it looks indeed like the Efficy.dll appends the current entity to the CreateRelation function...
indeed ... but this is worse because I only have the following script balise before the windows close in this case, so I don't know how the relation is created in this case :
<script>
Relocating = true
RefreshOpener(1026)
</script>
if this can help you Stephan I just try it on the Efficy 11 last build and the parent child relation is well created... I guess you just have to upgrade^^
0 votes

Hello Stéphane,

Before Efficy 11 indeed the entity and key of the newly created entity is added by Efficy.dll to the CreateRelation() call.

For example, if the action passed to the edit window for the new Property (entity 'Prop') is

action=CreateRelation(1005;Prop;60785)

then committing the new property will generate the script call

CreateRelation(1005,’Prop’,’60785’,’Prop’,’KeyOfNewProperty’)

CreateRelation is a generic method to create a link or relation between two entities. It can handle the case in which the user needs to modify some fields in the relation (e.g. as in linking a Contact to a Company), or the case in which you need to open an edit window of another entity to create the relation (e.g. as in linking a Company to a Document).
The method to use is specified in the CreateRelationMethod (which can be overridden in custom). For a standard entity-entity relation in a treeview the default method is "2" and a call to the function AddLink is made.

So in the end we have the following call:

AddLink(1005,’Prop’,’60785’,’Prop’,’KeyOfNewProperty’)

which generates the following call on the web server

var URL = "addlink?bookmark=1005&entity=Prop&key=60785&detail=Prop&detailkey=KeyOfNewProperty

Can you verify in the Efficy log that you get this call, with the correct parameters?

At the end of the day you should find a record in the database with KPROPERTY=60785 and KPROPERTY2=KeyOfNewProperty

In your testing environment apparently at some point the keys are swapped, and you end up with the opposite relation. I hope the information above will help you to find out at which point exactly the parameters are swapped.

Cheers,
Robert

answered by (1.2k points)
Dear Robert,

Thank you for your answer, I did check the custom "CreateRelationMethod" and for Prop_Prop relation we return "2" so an Add link.

So I check the log and in the log I can find a "addlink" log if I link an Existing property. But if I link a new property  (with the button Add in the search) then no log can be found on the "addlink" ... very weird.  so it seems like the DLL is doing the linking without writing in the log.

Do you have any idea were I could search ?

I forgot to mention that the customer is now in Efficy 10 R10150 (SP2 +)

Cheers,
Stéphane
I suggest that you add some alerts or breakpoints in the javascript function CreateRelation() to find out what happens.
I already tried this (cf in answer to Kristof)
But in the cate of creation of a new property, it seems that the CreateRelation function is not called we only see the following code when the windows is closing :

<!doctype html>
<html>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<head>
</head>
<body>
<script src ="../efficy/js/config/require.config.js" ></script>
<script src ="../efficy/../lib/js/vendor/require.js" ></script>
<script src ="../efficy/scripts/Base.js" ></script>
<script src ="../efficy/scripts/Efficy.js" ></script>
<script src ="../customs/cwuat/Custom.js" ></script>
<script>
Relocating = true
RefreshOpener(1022)
</script>
</body>
</html>


and the url when the windows is closing is : https://cwuat.efficytest.com/efficy.dll/commit?EDITHANDLE=75&BOOKMARK=1025&EDITFORM=1
1,249 questions
1,518 answers
1,858 comments
328 users