<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title>Efficy Overflow Q&amp;A - Recent questions tagged k_relation</title>
<link>https://overflow.efficy.io/?qa=tag/k_relation</link>
<description>Powered by Question2Answer</description>
<item>
<title>No RelationKey (optional) parameter for OnInsertDetailXxxxYyyy event</title>
<link>https://overflow.efficy.io/?qa=4629/relationkey-optional-parameter-oninsertdetailxxxxyyyy</link>
<description>&lt;p&gt;When scripting the OnInsertDetail event, we're not provided the (optional) relationKey parameter.&lt;br&gt;
Consequently, it becomes a nightmare when you want to edit the newly inserted detail relation : I hoped the new detail would be the last one in the detailDataset but its position is not reliable.&lt;/p&gt;

&lt;p&gt;This is to my mind a decent change request.&lt;/p&gt;

&lt;p&gt;I've tried set the SELECTORDERBY clause of the SYS&lt;em&gt;TABLEVIEWS to XXXX&lt;/em&gt;YYYY.D_CHANGE, but this isn't reliable.&lt;br&gt;
=&amp;gt; I use a custom fied to know if a detail has been processed or not by my workflow :-(&lt;/p&gt;

&lt;p&gt;Any comment is welcome.&lt;/p&gt;
</description>
<category>WorkFlow / Serverscript</category>
<guid isPermaLink="true">https://overflow.efficy.io/?qa=4629/relationkey-optional-parameter-oninsertdetailxxxxyyyy</guid>
<pubDate>Wed, 31 Jul 2019 09:45:55 +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>How to determine K_RELATION in DOCU_PROD using a direct database-update</title>
<link>https://overflow.efficy.io/?qa=3855/determine-krelation-docuprod-using-direct-database-update</link>
<description>&lt;p&gt;I'm trying to insert rows in the table DOCU_PROD using an external program. So I'm not able to use Efficy-functions. &lt;/p&gt;

&lt;p&gt;All columns are quite logical, but I'm not sure &lt;strong&gt;how to determine the content of K_RELATION&lt;/strong&gt;? Can I just define a random value? Or is it (as the name of the column suggests) a relation to another table? As far as I have seen the values do not need to be unique. &lt;/p&gt;

&lt;p&gt;Edit: I tried to set K&lt;em&gt;RELATION = 0. But when trying to edit the document afterwards it results in the following error: Vind detail met sleutel &quot;97&quot; en relatie &quot;612593356&quot; niet terug&lt;br&gt;
so somehow there must be a logical way to deterime K&lt;/em&gt;RELATION. Does someone know?&lt;/p&gt;
</description>
<category>Database</category>
<guid isPermaLink="true">https://overflow.efficy.io/?qa=3855/determine-krelation-docuprod-using-direct-database-update</guid>
<pubDate>Fri, 11 Jan 2019 20:39:27 +0000</pubDate>
</item>
<item>
<title>OnBeforeDeleteProdProj(key, detailKey, krelation) called with undefined krelation...</title>
<link>https://overflow.efficy.io/?qa=1526/onbeforedeleteprodproj-detailkey-krelation-undefined-krelation</link>
<description>&lt;p&gt;Hi, &lt;br&gt;
I added a K&lt;em&gt;RELATION column to the table &quot;PROD&lt;/em&gt;PROJ&quot;.&lt;/p&gt;

&lt;p&gt;It run well everywhere, except the  &lt;strong&gt;OnBeforeDeleteProdProj(key, detailKey, krelation)&lt;/strong&gt; function, which is call with an undefined value for the &quot;krelation&quot; parameter...&lt;/p&gt;

&lt;p&gt;Where is the problem ?&lt;br&gt;
Thanks&lt;br&gt;
Didier&lt;/p&gt;
</description>
<category>WorkFlow / Serverscript</category>
<guid isPermaLink="true">https://overflow.efficy.io/?qa=1526/onbeforedeleteprodproj-detailkey-krelation-undefined-krelation</guid>
<pubDate>Mon, 18 Apr 2016 11:44:48 +0000</pubDate>
</item>
</channel>
</rss>