<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title>Efficy Overflow Q&amp;A - Recent questions tagged create-relation</title>
<link>https://overflow.efficy.io/?qa=tag/create-relation</link>
<description>Powered by Question2Answer</description>
<item>
<title>Create a conditionnal DetailMenu</title>
<link>https://overflow.efficy.io/?qa=4302/create-a-conditionnal-detailmenu</link>
<description>&lt;p&gt;Hello, &lt;/p&gt;

&lt;p&gt;We would like to customise Efficy in order to have a &lt;code&gt;DetailMenu&lt;/code&gt;, with a condition in it.&lt;/p&gt;

&lt;p&gt;The macro is the following one : &lt;/p&gt;

&lt;pre&gt;&lt;code&gt;DetailMenu..Docu {[&amp;lt;%GetPopupMenu(id=&quot;detail-menu&quot;, class=&quot;has-icons small&quot;, ulargs='data-channel=&quot;detailmenu&quot;', count=&quot;6&quot;,
text1=&quot;Edit #DETAIL&quot;, image1=&quot;i-edit&quot;,
message1=&quot;edit;{dropdownKey};#DETAIL&quot;,
text2=&quot;Delete #DETAIL&quot;, image2=&quot;i-delete&quot;,
message2=&quot;deleteItem;#DETAIL;{dropdownKey}&quot;,
text3=&quot;Edit Relation&quot;, image3=&quot;i-link&quot;, onlinehelp3=&quot;e110_linkitems&quot;,
message3=`%%IfCategories(then=&quot;editRelation;#ENTITY;#KEY;#DETAIL;{dropdownKey}&quot;)`,
text4=&quot;Duplicate #DETAIL&quot;, image4=&quot;i-Dupl&quot;, onlinehelp4=&quot;e110_duplicateitems&quot;,
message4=&quot;duplicate;#DETAIL;{dropdownKey}&quot;,
text5=&quot;Mark as Handled&quot;, image5=&quot;i-done&quot;,
message5=&quot;markDocumentHandled;{dropdownKey};0&quot;,
text6=&quot;Convert to Opportunity&quot;, image6=&quot;i-Oppo&quot;, rights6=&quot;Oppo&quot;, onlinehelp6=&quot;e110_convertitems2salesopp&quot;,
message6=&quot;convertToEntity;Oppo;#DETAIL;{dropdownKey};Comp\\;Cont\\;Proj\\;Prod;true;NAME&quot;
)%&amp;gt;]}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;What I would like to do is detect the reference or a field value of the document to propose other options.&lt;br&gt;
But the dev on this cannot make it work.&lt;/p&gt;

&lt;p&gt;He tried this, but it does not seems to work &quot;efficiently&quot; (it always show the option, whatever the reference)&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;DetailMenu..Docu {[
&amp;lt;%GetPopupMenu(
id=&quot;detail-menu&quot;, class=&quot;has-icons small&quot;, ulargs='data-channel=&quot;detailmenu&quot;', count=&quot;7&quot;,
text1=&quot;Edit #DETAIL&quot;, image1=&quot;i-edit&quot;,
message1=&quot;edit;{dropdownKey};#DETAIL&quot;,
text2=&quot;Delete #DETAIL&quot;, image2=&quot;i-delete&quot;,
message2=&quot;deleteItem;#DETAIL;{dropdownKey}&quot;,
text3=&quot;Edit Relation&quot;, image3=&quot;i-link&quot;, onlinehelp3=&quot;e110_linkitems&quot;,
message3=`%%IfCategories(then=&quot;editRelation;#ENTITY;#KEY;#DETAIL;{dropdownKey}&quot;)`,
text4=&quot;Duplicate #DETAIL&quot;, image4=&quot;i-Dupl&quot;, onlinehelp4=&quot;e110_duplicateitems&quot;,
message4=&quot;duplicate;#DETAIL;{dropdownKey}&quot;,
text5=&quot;Mark as Handled&quot;, image5=&quot;i-done&quot;,
message5=&quot;markDocumentHandled;{dropdownKey};0&quot;,
text6=&quot;Convert to Opportunity&quot;, image6=&quot;i-Oppo&quot;, rights6=&quot;Oppo&quot;, onlinehelp6=&quot;e110_convertitems2salesopp&quot;,
message6=&quot;convertToEntity;Oppo;#DETAIL;{dropdownKey};Comp\\;Cont\\;Proj\\;Prod;true;NAME&quot;,
`%%OnField(&quot;MakeNCG&quot;, query=&quot;select CASE WHEN /*doc.REFERENCE LIKE 'DRAFT-%' OR */doc.REFERENCE LIKE 'NC-%' OR doc.id_kleos IS NOT NULL OR doc.F_INVOICE_STATUS &amp;lt; 4 THEN 0 ELSE 1 END AS MakeNCG from DOCUMENTS doc where doc.K_DOCUMENT = {dropdownKey}&quot;, value=1, then=&quot;text7=`Make NC Globalazzz`, image7=`i-edit`, message7=`NCGlobal;{dropdownKey}`&quot;, else=&quot;text7=`Make NC non`, image7=`i-edit`, message7=`NCGlobal;{dropdownKey}`&quot;)`
)%&amp;gt;]}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;I suppose there is a way to : &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Make this &quot;clean&quot;&lt;/li&gt;
&lt;li&gt;Avoid a SQL query&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Regards, &lt;/p&gt;

&lt;p&gt;Loïc&lt;/p&gt;
</description>
<category>Efficy/ Client side</category>
<guid isPermaLink="true">https://overflow.efficy.io/?qa=4302/create-a-conditionnal-detailmenu</guid>
<pubDate>Sun, 19 May 2019 12:05:15 +0000</pubDate>
</item>
<item>
<title>[Solution] Create and use a custom relation form for a K_RELATION between two Entities where there where no K_RELATION</title>
<link>https://overflow.efficy.io/?qa=3969/solution-relation-krelation-between-entities-krelation</link>
<description>&lt;p&gt;Hello Efficy Team, &lt;/p&gt;

&lt;p&gt;Because I would like that the Overflow become the source of knowledge for all our daily customisation, I took some time to put in a post a &quot;tricky&quot; customisation. This kind of demands are often asked by customer and we don't always respond to it the right way.&lt;/p&gt;

&lt;h2&gt;Create a custom relation form between Project and Contacts, using a K_RELATION&lt;/h2&gt;

&lt;h3&gt;First step : add a K&lt;em&gt;RELATION in PPROJ&lt;/em&gt;CONT&lt;/h3&gt;

&lt;p&gt;For the context: Efficy is used to manage the leasing of products. Each product can be lease to the same person at different moment. There is always one contact for a single period, but the same contact could lease the same product (or collection of product) multiple time. This is why we use project and we need a K_RELATION.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://overflow.efficy.com/?qa=blob&amp;amp;qa_blobid=13734223560222336668&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;

&lt;p&gt;Adding the K&lt;em&gt;RELATION is quite simple. Just add the field &quot;K&lt;/em&gt;RELATION&quot; in the sys&lt;em&gt;fields with DbEditor (with almost the same parameters as the K&lt;/em&gt;PROJECT and the K_CONTACT).&lt;/p&gt;

&lt;p&gt;Then make an apply structure.&lt;/p&gt;

&lt;h3&gt;Second (very easy) step : creating the form in the designer&lt;/h3&gt;

&lt;p&gt;This is the easiest part. Use the designer to create a new form on the table &quot;PROJ_CONT&quot;. Add the field that you've created. &lt;/p&gt;

&lt;p&gt;Don't forget to write the K_FORM somewhere, this will be useful for the next step.&lt;/p&gt;

&lt;h3&gt;Add the &quot;modify relation&quot; button and show the form&lt;/h3&gt;

&lt;p&gt;2 macros need to be modified : &lt;/p&gt;

&lt;pre&gt;&lt;code&gt;MacroConsultCustom

DetailMenu.Proj.Cont {[&amp;lt;%GetPopupMenu(id=&quot;detail-menu&quot;, class=&quot;has-icons small&quot;, ulargs='data-channel=&quot;detailmenu&quot;', count=&quot;4&quot;,
     text1=&quot;Edit #DETAIL&quot;, image1=&quot;i-edit&quot;,
     message1=&quot;edit;{dropdownKey};#DETAIL&quot;,
     text2=&quot;Edit Relation&quot;, image2=&quot;i-link&quot;, onlinehelp2=&quot;e110_linkitems&quot;,
     message2=`editRelation;#ENTITY;#KEY;#DETAIL;{dropdownKey}`,
     text3=&quot;Delete Relation&quot;, image3=&quot;i-delete&quot;, onlinehelp3=&quot;e110_linkitems&quot;,
     message3=&quot;deleteRelation;#ENTITY;#KEY;#DETAIL;{dropdownKey}&quot;,
     text4=&quot;Add Call Back Task&quot;, image4=&quot;i-callback&quot;,  onlinehelp4=&quot;e110_createcallbacktasks&quot;,
     message4=&quot;addCallBack;#ENTITY;#KEY;;{dropdownKey}&quot; 
)%&amp;gt;]}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Then you use the K_FORM of your new &quot;custom Project - Contact&quot;&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;MacroRelationCustom

RelationSectionsForm.Proj.Cont {[2]}
&lt;/code&gt;&lt;/pre&gt;

&lt;h3&gt;Editing the &quot;good&quot; relation&lt;/h3&gt;

&lt;p&gt;If you tested so far, you should see that you can &quot;edit the relation&quot; and your form is showing. But unfortunately, it does not show you current relation. Because we didn't specified witch relation need to be updated.&lt;/p&gt;

&lt;p&gt;We first need to retrieve the K&lt;em&gt;RELATION. For that, we'll duplicate the &quot;K&lt;/em&gt;MASTER=0;K&lt;em&gt;DETAIL=11&quot; and we'll create a new &quot;K&lt;/em&gt;MASTER=20;K_DETAIL=11&quot;&lt;/p&gt;

&lt;p&gt;We just add the K_RELATION on the column &quot;by default&quot; retrieved :&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://overflow.efficy.com/?qa=blob&amp;amp;qa_blobid=2308786652932697884&quot; alt=&quot;enter image description here&quot;&gt;&lt;/p&gt;

&lt;p&gt;Then we'll overload the default &quot;consult queries&quot; for the relation &quot;PROJ_CONT&quot; :&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;MacroConsultCustom :

ConsultQueries.Proj.Cont {[
&amp;lt;%RunQuery(id=&quot;MainComp&quot;, SQL=&quot;select C.K_COMPANY, C.NAME from &amp;lt;#table name='PROJ_COMP'&amp;gt; PC, &amp;lt;#table name='COMPANIES'&amp;gt; C
    where C.K_COMPANY = PC.K_COMPANY and PC.K_PROJECT=:param1 and PC.MAIN=1&quot;, param1=&quot;#K&quot;, store=&quot;1&quot;)%&amp;gt;
&amp;lt;%RunQuery(id=&quot;MainCont&quot;, SQL=&quot;select C.K_CONTACT, C.NAME, C.MIDDLENAME, C.FIRSTNAME from &amp;lt;#table name='PROJ_CONT'&amp;gt; PC, &amp;lt;#table name='CONTACTS'&amp;gt; C
    where C.K_CONTACT = PC.K_CONTACT and PC.K_PROJECT=:param1 and PC.MAIN=1&quot;, param1=&quot;#K&quot;, store=&quot;2&quot;)%&amp;gt;

&amp;lt;%RunQuery(id=&quot;ListCont&quot;, MASTER=&quot;20&quot;, DETAIL=&quot;11&quot;, param1=&quot;%%GetKey()&quot;, mainquery=&quot;true&quot;)%&amp;gt; ]}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;We also need to change the &quot;{dropdownKey}&quot; argument passed by our detailMenu (edited before). Efficy know the relation to edit by following this rule : &quot;detailKey_relationKey&quot;. To do this, we'll overload the &quot;MENU&quot; definition, with this new rule : &lt;/p&gt;

&lt;pre&gt;&lt;code&gt;MacroConsultCustom :

DetailGridColumns.Proj.Cont     {[MENU{RELATIONMENU},NAME,MIDDLENAME,FIRSTNAME{NAME},PHONE1{PHONE},PHONE2{PHONE},EMAIL1{EMAIL}]}

GridColumnCustom : 

th.RELATIONMENU {[&amp;lt;th class=&quot;icon-cell hide-for-print&quot;&amp;gt; &amp;lt;/th&amp;gt;]}
td.RELATIONMENU {[&amp;lt;td class=&quot;menu icon-cell hide-for-print&quot;&amp;gt;&amp;lt;span class=&quot;dropdown no-pip i-menu small&quot; hello data-dropdown=&quot;detail-menu&quot; data-args=&quot;&amp;lt;#F=K_CONTACT;context=ATTR&amp;gt;_&amp;lt;#F=K_RELATION;context=ATTR&amp;gt;&quot;&amp;gt;&amp;lt;/span&amp;gt;&amp;lt;/td&amp;gt;]} 
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Then, ... it is done ! You'll be able to Edit the relation between project and contact, starting from the project. In my specific case it wasn't asked to do it starting from the contact itself but it wouldn't be hard to modify.&lt;/p&gt;

&lt;p&gt;I hope it help you in the future, &lt;/p&gt;

&lt;p&gt;Loïc&lt;/p&gt;
</description>
<category>Efficy/ Client side</category>
<guid isPermaLink="true">https://overflow.efficy.io/?qa=3969/solution-relation-krelation-between-entities-krelation</guid>
<pubDate>Tue, 19 Feb 2019 19:32:31 +0000</pubDate>
</item>
<item>
<title>Trouble ceating a relation between Cont and new entity</title>
<link>https://overflow.efficy.io/?qa=3743/trouble-ceating-a-relation-between-cont-and-new-entity</link>
<description>&lt;p&gt;Hi,&lt;/p&gt;

&lt;p&gt;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 &lt;/p&gt;

&lt;p&gt;Error: WKFL-2142 Error while executing script &quot;bentest&quot; at line 1020 char 4. (File &quot;C:\inetpub\wwwroot\11.0\customs\xxx\serverscripts\NL&lt;em&gt;server&lt;/em&gt;test.js&quot; line 25)&lt;br&gt;
Message: &quot;Incorrect Detail for Edit Context&quot;&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;function bentest() {
    var editHandle = Efficy.openEditContext(ntCont, 67067, false);
        try{
            var ds = Efficy.getMasterDataSet(editHandle, 0);
            ds.edit();
            Efficy.insertDetail2(editHandle, 50, 64, false);
            Efficy.commitChanges(editHandle, true);
        } finally {
            Efficy.closeContext(editHandle);
        }   
}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;line 25 is the insertDetail2 line.&lt;/p&gt;
</description>
<category>Efficy Partners</category>
<guid isPermaLink="true">https://overflow.efficy.io/?qa=3743/trouble-ceating-a-relation-between-cont-and-new-entity</guid>
<pubDate>Wed, 12 Dec 2018 10:00:16 +0000</pubDate>
</item>
<item>
<title>Best method to override search</title>
<link>https://overflow.efficy.io/?qa=3551/best-method-to-override-search</link>
<description>&lt;p&gt;Hi Guys,&lt;/p&gt;

&lt;p&gt;I was wondering if there's a nice and clean way to override the result of the search page with a custom function?&lt;/p&gt;

&lt;p&gt;What i need is the following:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Open the standard search window from a relational detailmenu with the normal search features of Efficy and the createrelation action (so you can also create a new relational record)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;If you click on one of the search result records, a custom function needs to start.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Hopefully someone has a simple way to do it, instead of overriding all pages and macro's.&lt;/p&gt;

&lt;p&gt;Kr,&lt;/p&gt;

&lt;p&gt;Michael de Groot&lt;/p&gt;
</description>
<category>Efficy/ Client side</category>
<guid isPermaLink="true">https://overflow.efficy.io/?qa=3551/best-method-to-override-search</guid>
<pubDate>Mon, 17 Sep 2018 10:25:55 +0000</pubDate>
</item>
<item>
<title>CreateRelation on new Entity : how does this work ?</title>
<link>https://overflow.efficy.io/?qa=3063/createrelation-on-new-entity-how-does-this-work</link>
<description>&lt;p&gt;Dear All,&lt;/p&gt;

&lt;p&gt;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 : &lt;/p&gt;

&lt;p&gt;1- when I click on the + button in the consult, it open the search window with the parameter &lt;br&gt;
&quot;action=CreateRelation(1009%3BProp%3B1186)&quot; ... 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.&lt;/p&gt;

&lt;p&gt;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 &quot;action=CreateRelation(1009%3BProp%3B1186)&quot;&lt;br&gt;
But when I clicked on &quot;OK&quot; or &quot;APPLY&quot;, 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 ... &lt;/p&gt;

&lt;p&gt;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.&lt;/p&gt;

&lt;p&gt;And I don't  know where this happened.&lt;/p&gt;

&lt;p&gt;PS : I suspect that this is handled in the Efficy.dll ... but I would like a confirmation of it.&lt;/p&gt;

&lt;p&gt;Best Regards,&lt;br&gt;
Stéphane&lt;/p&gt;
</description>
<category>WorkFlow / Serverscript</category>
<guid isPermaLink="true">https://overflow.efficy.io/?qa=3063/createrelation-on-new-entity-how-does-this-work</guid>
<pubDate>Thu, 12 Apr 2018 12:19:10 +0000</pubDate>
</item>
</channel>
</rss>