NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

<?xml version="1.0" encoding="utf-8"?>
<!-- This script will be executed on a AfterDeploy exitpoint. -->

<!-- History

09/02/2015 : Fixed bug (solution: no import of tags /printer tags if there are none), uncommented RecreateMetadataInCrm
06/02/2015 : Temporary commented RecreateMetadataInCrm for manual start script

26-01-2015 : Extend getAccountId to take in account that the project can exist multiple times on different roles

INFO: Since there can be several project with the same project name (on different roles), we take the account key as present in the organization url in the CRM server variable if there are multiple projects with the same name.
If there is just one project with that project name, this account key does not have to (and will not be) taken into account)

11-03-2015 LoadXmlDoc via DOM, om rootelement van exportable te negeren.
Toevoegen namespace sectie.

-->
<XBscript>
<Namespaces>
<Namespace prefix="'xbi'" uri="'http://xml.invenso.com/schema/XBiTypes'"/>
</Namespaces>

    <Imports>
        <Import script="'../Utilities/ReCreateMetadataInCrm.xb'" />
     <Import item="'../Base/DataBase/XDCrm.dblink'" />
        <Import schema="'projecttemplate.xsd'" />
    </Imports>
     
    <Data>
        <Field name="projectName" datatype="string" />
        <Field name="databaseManager" datatype="XDCrmManager" />
    </Data>
    <!-- Main method that will be executed by exit point -->
    <Main>
        <!-- Project xml that is given as input with an AfterDeploy exitpoint. -->
        <Parm name="input" datatype="Project" />

<Try>



<!-- Start transaction -->
<Eval exp="databaseManager.startTransaction()" />

        <Set var="projectName" value="input.name" />

<!-- get account id -->
<Field name="accountId" datatype="int" />
<Set var="accountId" value="getAccountId()" />
         
        <ForEach in="input.Group" var="group">
            <CallRoutine name="'HandleGroup'" group="group" accountId="accountId" />
        </ForEach>
        <ForEach in="input.Item" var="item">
            <CallRoutine name="'HandleItem'" item="item" accountId="accountId" />
        </ForEach>

<!-- Commit transaction -->
<Eval exp="databaseManager.commitTransaction()" />

<Catch var="error">
<!-- Rollback transaction -->
<!--<Eval exp="databaseManager.rollbackTransaction()" />-->
<Log msg="error.message" level="'fatal'" />
</Catch>

<RunScript script="'../Utilities/ReCreateMetadataInCrm.xsa'">
<Input value="projectName" />
</RunScript>

</Try>


          
        <Return value="input.toXml()" />
    </Main>
     
     <!-- handle group that can contains subgroups and/or items -->
    <Routine name="HandleGroup">
        <Parm name="group" datatype="Group" />
<Parm name="accountId" datatype="int" />
        <ForEach in="group.Group" var="subGroup">
            <CallRoutine name="'HandleGroup'" group="subGroup" accountId="accountId" />
        </ForEach>


        <!-- Only handle items in 'Templates' group -->
        <If condition="group.name eq 'Templates'">
            <ForEach in="group.Item" var="item">
                <CallRoutine name="'HandleItem'" item="item" accountId="accountId" />
            </ForEach>

<!-- handle general properties -->
<CallRoutine name="'HandleGeneralProperties'" group="group" accountId="accountId"/>
        </If>
         
    </Routine>
     
     <!-- handle item -->
    <Routine name="HandleItem">
        <Parm name="item" datatype="Item" />
<Parm name="accountId" datatype="int" />
          
         <!-- Get property from database -->
         <Eval exp="importXDDATA(item,accountId)" />
         
    </Routine>

<!-- handle template group for putting general properties like tags in Template group -->
<Routine name="HandleGeneralProperties">
<Parm name="accountId" datatype="int" />
<Parm name="group" datatype="Group" />

<Field name="property" datatype="Property" />
<ForEach in="group.Properties.Property" var="property">
<If condition="property.key eq 'tags'">
<CallRoutine name="'insertTags'" accountId="accountId" tags="property.value" />
</If>
<If condition="property.key eq 'languageMappings'">
<CallRoutine name="'insertLanguageMappings'" accountId="accountId" languageMappings="property.value" />
</If>
<If condition="property.key eq 'printertags'">
<CallRoutine name="'insertPrinterTags'" accountId="accountId" languageMappings="property.value" />
</If>
</ForEach>

</Routine>

<Routine name="insertLanguageMappings">
<Parm name="accountId" datatype="int" />
<Parm name="languageMappings" datatype="string" />

<Field name="xddataRecord" datatype="xddata" />
<Set var="xddataRecord.idAccount" value="accountId" />
<Set var="xddataRecord.keyType" value="'metadata'" />
<Set var="xddataRecord.keySubtype" value="'language-mappings'" />
<Set var="xddataRecord.keyValue" value="''" />
<Set var="xddataRecord.keyData" value="languageMappings" />

<Field name="xddataen" datatype="xddatas" />
<!-- <Set var="xddataen" value="databaseManager.selectxddatabyKeys(xddataRecord.idAccount,xddataRecord.keyValue,xddataRecord.keyType,xddataRecord.keySubtype)" /> -->
<Set var="xddataen" value="databaseManager.selectxddataByTypeAndValue(xddataRecord.keyType,xddataRecord.keySubtype,xddataRecord.keyValue,xddataRecord.idAccount)" />

<If condition="xddataen.xddata.size() eq 0">

<Field name="xd" datatype="xddata" />
<ForEach in="xddataen.xddata" var="xd">
<Set var="xd.idData" value="null" />
</ForEach>


<!-- insert xddata record in database -->
<Eval exp="databaseManager.insertxddata(xddataRecord)" />

<Else>
<Set var="xddataRecord.idData" value="xddataen.xddata[0].idData" />
<Eval exp="databaseManager.updatexddata(xddataRecord)" />
</Else>
</If>


</Routine>

<Routine name="insertTags">
<Parm name="accountId" datatype="int"/>
<Parm name="tags" datatype="string" />

<Field name="xddataRecord" datatype="xddata" />
<Set var="xddataRecord.idAccount" value="accountId" />
<Set var="xddataRecord.keyType" value="'metadata'" />
<Set var="xddataRecord.keySubtype" value="'tags'" />
<Set var="xddataRecord.keyValue" value="''" />
<Set var="xddataRecord.keyData" value="tags" />

<Field name="xddataen" datatype="xddatas" />
<Set var="xddataen" value="databaseManager.selectxddataByTypeAndValue(xddataRecord.keyType,xddataRecord.keySubtype,xddataRecord.keyValue,xddataRecord.idAccount)" />

<If condition="xddataRecord.keyData ne ''">


<If condition="xddataen.xddata.size() eq 0">

<Set var="xddataRecord.idData" value="null" />

<!-- insert xddata record in database -->
<Eval exp="databaseManager.insertxddata(xddataRecord)" />

<Else>
<Set var="xddataRecord.idData" value="xddataen.xddata[0].idData" />
<Eval exp="databaseManager.updatexddata(xddataRecord)" />
</Else>
</If>
</If>
</Routine>

<Routine name="insertPrinterTags">
<Parm name="accountId" datatype="int" />
<Parm name="languageMappings" datatype="string" />

<Field name="xddataRecord" datatype="xddata" />
<Set var="xddataRecord.idAccount" value="accountId" />
<Set var="xddataRecord.keyType" value="'metadata'" />
<Set var="xddataRecord.keySubtype" value="'printer-tags'" />
<Set var="xddataRecord.keyValue" value="''" />
<Set var="xddataRecord.keyData" value="languageMappings" />

<Field name="xddataen" datatype="xddatas" />
<!-- <Set var="xddataen" value="databaseManager.selectxddatabyKeys(xddataRecord.idAccount,xddataRecord.keyValue,xddataRecord.keyType,xddataRecord.keySubtype)" /> -->
<Set var="xddataen" value="databaseManager.selectxddataByTypeAndValue(xddataRecord.keyType,xddataRecord.keySubtype,xddataRecord.keyValue,xddataRecord.idAccount)" />

<If condition="xddataRecord.keyData ne ''">
<If condition="xddataen.xddata.size() eq 0">
<Set var="xddataRecord.idData" value="null" />

<!-- insert xddata record in database -->
<Eval exp="databaseManager.insertxddata(xddataRecord)" />

<Else>
<Set var="xddataRecord.idData" value="xddataen.xddata[0].idData" />
<Eval exp="databaseManager.updatexddata(xddataRecord)" />
</Else>
</If>
</If>

</Routine>

     
    <Routine name="importXDDATA">
        <Parm name="item" datatype="Item" />
<Parm name="accountId" datatype="int" />
         
        <FieldList name="xddatas" datatype="string" />
         
        <!-- get keyValue for that item -->
        <Field name="keyValue" datatype="string" />
        <Set var="keyValue" value="determinekeyValue(item)" />
         
        <Field name="xddataen" datatype="xddatas" />
         
        <!-- insert properties in database -->
        <Eval exp="insertPropertiesInDatabase(item,accountId,keyValue)" />
         
    </Routine>
     
    <!-- Inserts properties in database if not already in database -->
    <Routine name="insertPropertiesInDatabase">
        <Parm name="item" datatype="Item" />
        <Parm name="idAccount" datatype="int" />
        <Parm name="keyValue" datatype="string" />

<FieldList name="propertyen" datatype="Property" />
<If condition="!isNull(item.Properties)">

<Set var="propertyen" value="item.Properties.Property" />
<If condition="!isNull(propertyen) and propertyen.size() gt 0">

<Field name="prop" datatype="Property" />
         <Field name="i" datatype="int" />



<DoWhile condition="i lt propertyen.size()">
          <Set var="prop" value="item.Properties.Property[i]"/>
        
<!-- keyType and keySubtype are put in prop.key, with a '-' delimiter -->
<Field name="delimiter" datatype="int" />
<Set var="delimiter" value="indexOf(prop.key, '-delimiter-')" />
<Field name="endPos" datatype="int" />
<Set var="endPos" value="length(prop.key)" />
<Field name="xddatarecord" datatype="xddata" />
<Set var="xddatarecord.keyType" value="substr(prop.key,0,delimiter)" />
<Set var="xddatarecord.keySubtype" value="substr(prop.key,delimiter+11,endPos)" />
            
            <Set var="xddatarecord.keyData" value="prop.value" />
           
            <Set var="xddatarecord.idAccount" value="idAccount" />
            
            <Set var="xddatarecord.keyValue" value="keyValue" />

<!-- Check if that xddata record already exists in database -->
     <Field name="xddataen" datatype="xddatas" />
<!--<Set var="xddataen" value="databaseManager.selectxddatabyKeys(idAccount,keyValue,xddatarecord.keyType,xddatarecord.keySubtype)" />-->

<Set var="xddataen" value="databaseManager.selectxddataByTypeAndValue(xddatarecord.keyType,xddatarecord.keySubtype,xddatarecord.keyValue,idAccount)" />




        <If condition="xddataen.xddata.size() eq 0">

 <!-- insert xddata record in database -->
            <Eval exp="databaseManager.insertxddata(xddatarecord)" />

<Else>
<Set var="xddatarecord.idData" value="xddataen.xddata[0].idData" />
<Eval exp="databaseManager.updatexddata(xddatarecord)" />
</Else>
         </If>

<Set var="i" value="i+1" />
</DoWhile>


</If>
</If>
    </Routine>
     
    <Routine name="getAccountId">
<!-- Get account id from database -->
<Field name="accountId" datatype="int" />


<!-- Get all accounts -->
<Field name="accounts" datatype="accounts" />
<Set var="accounts" value="databaseManager.selectAllaccounts()" />

<!-- Get account key -->
<Field name="accKey" />
<Set var="accKey" value="getAccountKey()" />

<!-- Get all account_projects with that project name -->
<Field name="account_projects" datatype="account_projects" />
<Set var="account_projects" value="databaseManager.selectaccount_projectgetAccountIdByProject(projectName)" />
<Set var="accountId" value="account_projects.account_project[0].account_id" />


<Field name="acc_proj" datatype="account_project" />


<!-- loop through all account_projects with that account key -->
<Field name="acc" datatype="account" />
<ForEach in="accounts.account" var="acc">
<If condition="acc.key eq accKey">
<!-- loop through all related account_projects from that project -->
<Set var="accountId" value="acc.id" />
</If>
</ForEach>

<Return value="accountId" />
</Routine>

<Routine name="getAccountKey">

<Set var="CrmServer" value="external('/'+projectName+'/mscrm.CrmServer')" />

<Field name="return" />

<LoadXmlDoc var="CrmServer" access="'DOM'" namespaceAware="true" />
<Select xpath="'//xbi:CRMServer'">
<Set var="return" value="$@organization" />
</Select>


<Return value="return" />

</Routine>
     
    <Routine name="determinekeyValue">
        <Parm name="item" datatype="Item" />

<Set var="templateName" value="'/templates/'+toLower(item.name)" />
<!-- templateName contains keyvalue with preceding /<projectname>. We need to remove this first part. -->
<!-- <Field name="firstPartLength" datatype="int" />
<Set var="firstPartLength" value="length(projectName)+1" />
<Field name="keyValue" datatype="string" /> -->

<!-- <Return value="substr(templateName,firstPartLength ,length(templateName) )" /> -->
<Return value="templateName" />
    </Routine>
</XBscript>
     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.