<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title>Efficy Overflow Q&amp;A - Recent questions tagged insertdetail2</title>
<link>https://overflow.efficy.io/?qa=tag/insertdetail2</link>
<description>Powered by Question2Answer</description>
<item>
<title>InsertDetail AfterCommit</title>
<link>https://overflow.efficy.io/?qa=6131/insertdetail-aftercommit</link>
<description>&lt;p&gt;Hello&lt;br&gt;
I'm trying to add a specific project to a case after the commit. It should happen after the commit, because I need to look at the MAINComp to see which project should be linked. If I do it BeforCommit, the CASE&lt;em&gt;COMP relation is not added, so I can't access the K&lt;/em&gt;COMPANY of the MAINComp.&lt;/p&gt;

&lt;p&gt;I execute the following code :&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;function AfterCommitCase(EditHandle, Inserted) {
    StartDebug('AfterCommitCase')
    CheckEntitySecurity(EditHandle, Inserted, 'Case')   

    if(Inserted) {
        var dsCase = Database.GetMasterDataSet(EditHandle, 0);
        dsCase.Edit    
        var K_CASE = dsCase.FieldByName('K_CASE').AsString
        var EditCase = Database.OpenEditContext(ntCase, K_CASE)
        var SQL = &quot;...&quot;
        var QueryEx = new QueryExecuter();
        var K_PROJECT = QueryEx.FirstColumn(SQL, K_CASE, 0)
        if (K_PROJECT &amp;gt; 0) {
            Database.InsertDetail2(EditCase, ntProj, K_PROJECT, false) 
        }

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

&lt;p&gt;The K_PROJECT that I get returned is correct, but the InsertDetail2 doesn't work. I tried the EditCase but also the EditHandle from the parameter.&lt;/p&gt;

&lt;p&gt;Is there a way to insert details in the AfterCommit or get the CASE_COMP relation in BeforeCommit?&lt;/p&gt;
</description>
<category>WorkFlow / Serverscript</category>
<guid isPermaLink="true">https://overflow.efficy.io/?qa=6131/insertdetail-aftercommit</guid>
<pubDate>Thu, 27 May 2021 09:30:44 +0000</pubDate>
</item>
<item>
<title>How to use InsertDetail</title>
<link>https://overflow.efficy.io/?qa=1393/how-to-use-insertdetail</link>
<description>&lt;p&gt;I added a field F_PROJECT to the entity Actions which shows a lookuplist with a selection of our projects. This list works fine and the results are saved correctly. &lt;/p&gt;

&lt;p&gt;The only thing I want to add now is that the project chosen in this list is added as main linked project. So I need to add a bit of workflow script with the database edit method InsertDetail or InsertDetail2 but I am not sure which one to choose and how to use these methods. Can someone give me an example of a similar script or explain how to do this? edn.efficy.com does not give enough explanation for me to accomplish this.&lt;/p&gt;

&lt;p&gt;thnx!&lt;/p&gt;
</description>
<category>Efficy Partners</category>
<guid isPermaLink="true">https://overflow.efficy.io/?qa=1393/how-to-use-insertdetail</guid>
<pubDate>Mon, 07 Mar 2016 17:40:44 +0000</pubDate>
</item>
</channel>
</rss>