<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title>Efficy Overflow Q&amp;A - Recent questions tagged edit-relation</title>
<link>https://overflow.efficy.io/?qa=tag/edit-relation</link>
<description>Powered by Question2Answer</description>
<item>
<title>Is it better to &quot;openEditContextRelation&quot; or &quot;TDataSet.edit() / TDataSet.post()&quot; ?</title>
<link>https://overflow.efficy.io/?qa=4356/better-openeditcontextrelation-tdataset-edit-tdataset-post</link>
<description>&lt;p&gt;Hello, &lt;/p&gt;

&lt;p&gt;Let's imagine I need to mass update the quantity of the products linked to a document.&lt;/p&gt;

&lt;p&gt;Would it be better to do : &lt;br&gt;
&lt;strong&gt;The &quot;openEditContextRelation&quot; method&lt;/strong&gt;&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;var dsProducts = Efficy.getDetailDataSet(docuCtx, ntProd);
            if(dsProducts.isEmpty()) return;

            dsProducts.first();

while (!dsProducts.eof()) {

                var docuProdCtx = Efficy.openEditContextRelation(ntDocu, ntProd, this.k_document, dsProducts.fieldByName('K_PRODUCT').asFloat, dsProducts.fieldByName('K_RELATION').asFloat)
                try {

                    var dsDocuProd = Efficy.getMasterDataSet(docuProdCtx, 0);
                    dsDocuProd.edit();

                    dsDocuProd.fieldByName('QUANTITY').asInteger = -1;
                    dsDocuProd.fieldByName('TOTAL').asFloat = - dsProducts.fieldByName('TOTAL').asFloat;
                    dsDocuProd.fieldByName('F_TOTAL_TVAC').asFloat = - dsProducts.fieldByName('F_TOTAL_TVAC').asFloat;

                    if(dsProducts.fieldByName('F_ISTIMESHEET').asInteger) {
                        this.Time.lockManagement(dsProducts.fieldByName('F_EXT_KEY').asFloat, 1, 0);
                    }

                    Efficy.commitChanges(docuProdCtx, false);

                } finally {
                   Efficy.closeContext(docuProdCtx)
                }

            }
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;or the &lt;strong&gt;TDataSet.edit() / TDataSet.post()&lt;/strong&gt; ( &lt;strong&gt;&lt;em&gt;My personal choice&lt;/em&gt;&lt;/strong&gt; )&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;var dsProducts = Efficy.getDetailDataSet(docuCtx, ntProd);
            if(dsProducts.isEmpty()) return;

            dsProducts.first();

            while (!dsProducts.eof()) {

                dsProducts.edit();

                dsProducts.fieldByName('QUANTITY').asInteger = -1;
                dsProducts.fieldByName('TOTAL').asFloat = - dsProducts.fieldByName('TOTAL').asFloat;
                dsProducts.fieldByName('F_TOTAL_TVAC').asFloat = - dsProducts.fieldByName('F_TOTAL_TVAC').asFloat;

                if(dsProducts.fieldByName('F_ISTIMESHEET').asInteger) {
                    this.Time.lockManagement(dsProducts.fieldByName('F_EXT_KEY').asFloat, 1, 0);
                }

                dsProducts.post();
                dsProducts.next();

            }
// this operation end with a commit on docuCtx and a closeContext
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;I never saw the second choice anywhere, in the old project I manage. Is it really a good idea ? I found more convinient to use the &lt;code&gt;TDataSet.edit()&lt;/code&gt; / &lt;code&gt;TDataSet.post()&lt;/code&gt; method, because you don't need to commit at each iteration; &lt;/p&gt;

&lt;p&gt;Thanks in advance, &lt;/p&gt;

&lt;p&gt;Loïc&lt;/p&gt;
</description>
<category>WorkFlow / Serverscript</category>
<guid isPermaLink="true">https://overflow.efficy.io/?qa=4356/better-openeditcontextrelation-tdataset-edit-tdataset-post</guid>
<pubDate>Sat, 25 May 2019 19:36:06 +0000</pubDate>
</item>
<item>
<title>Edit relation in Modal Window</title>
<link>https://overflow.efficy.io/?qa=4131/edit-relation-in-modal-window</link>
<description>&lt;p&gt;Has anyone already created a form in a Modal window for editing the relation (for ex. Prod &amp;amp; Oppo)?&lt;br&gt;
If so could you explain how you did this ?&lt;/p&gt;
</description>
<category>Efficy/ Client side</category>
<guid isPermaLink="true">https://overflow.efficy.io/?qa=4131/edit-relation-in-modal-window</guid>
<pubDate>Tue, 23 Apr 2019 12:06:09 +0000</pubDate>
</item>
</channel>
</rss>