Clarity

 View Only
  • 1.  Creating object instances using custom process

    Posted Dec 11, 2019 03:15 AM
    Hello,
    Is it possible to create a custom process that includes creating an object instance (e.g. cost plan) using the parent object as parameter?

    Our users want to automate creating cost plans based on financial gaps that exist in projects' financial plans (e.g. Team Detail hours do not match Sandbox hours).

    regards,
    Rhine


    ------------------------------
    Rhine
    ------------------------------


  • 2.  RE: Creating object instances using custom process
    Best Answer

    Posted Dec 19, 2019 08:41 AM
    Hi,
    there shouldn't be any problems. if you want to create a object instance, you need to use the write XOG in the gelscript.

    Don't know exactly how you want to implement it but, i Think something like this could be done:
    • Create a process
    • Include the starting condition if it's going to be automatically triggered or just schedule it to execute at a certain time.
    • Create a gelscript
    • Read the data you need
    • include in the gelscript the write XOG for the object instance and replace the parameters with the variables containing the specific data for the instance you want to create (one of the write XOG should be the parent_id
    • call the XOG so it's written in the DB

    This is an example of a process we developed some time ago to create a Cost Plan instance on Project Creation:
     <gel:parse var="x_escritura">
        <NikuDataBus xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../xsd/nikuxog_costPlan.xsd">
          <Header action="write" externalSource="NIKU" objectType="costPlan" version="14.4.0.234"/>
          <CostPlans>
            <CostPlan benefitPlanCode="" code="${v_cpcode}" finishPeriod="${v_finplan}" investmentCode="${v_invcode}" investmentType="project"
              isPlanOfRecord="true" name="${v_nombre}" periodType="MONTHLY" revision="0" startPeriod="${v_inicioplan}">
              <Description>${v_descripcion}</Description>
              <GroupingAttributes>
                <GroupingAttribute>resource_class_id</GroupingAttribute>
              </GroupingAttributes>
              <Details>
                <Detail>
                  <Cost/>
                  <Units/>
                  <Revenue/>
                  <GroupingAttributes>
                    <GroupingAttribute code="resource_class_id" value="Interno"/>
                  </GroupingAttributes>
                  <CustomInformation>
                    <ColumnValue name="partition_code">NIKU.ROOT</ColumnValue>
                  </CustomInformation>
                </Detail>
                <Detail>
                  <Cost/>
                  <Units/>
                  <Revenue/>
                  <GroupingAttributes>
                    <GroupingAttribute code="resource_class_id" value="OtrGast"/>
                  </GroupingAttributes>
                  <CustomInformation>
                    <ColumnValue name="partition_code">NIKU.ROOT</ColumnValue>
                  </CustomInformation>
                </Detail>
                <Detail>
                  <Cost/>
                  <Units/>
                  <Revenue/>
                  <GroupingAttributes>
                    <GroupingAttribute code="resource_class_id" value="PryCerr"/>
                  </GroupingAttributes>
                  <CustomInformation>
                    <ColumnValue name="partition_code">NIKU.ROOT</ColumnValue>
                  </CustomInformation>
                </Detail>
                <Detail>
                  <Cost/>
                  <Units/>
                  <Revenue/>
                  <GroupingAttributes>
                    <GroupingAttribute code="resource_class_id" value="CONSNEGG"/>
                  </GroupingAttributes>
                  <CustomInformation>
                    <ColumnValue name="partition_code">NIKU.ROOT</ColumnValue>
                  </CustomInformation>
                </Detail>
                <Detail>
                  <Cost/>
                  <Units/>
                  <Revenue/>
                  <GroupingAttributes>
                    <GroupingAttribute code="resource_class_id" value="EXTGRUP"/>
                  </GroupingAttributes>
                  <CustomInformation>
                    <ColumnValue name="partition_code">NIKU.ROOT</ColumnValue>
                  </CustomInformation>
                </Detail>
                <Detail>
                  <Cost/>
                  <Units/>
                  <Revenue/>
                  <GroupingAttributes>
                    <GroupingAttribute code="resource_class_id" value="VIAJES"/>
                  </GroupingAttributes>
                  <CustomInformation>
                    <ColumnValue name="partition_code">NIKU.ROOT</ColumnValue>
                  </CustomInformation>
                </Detail>
                <Detail>
                  <Cost/>
                  <Units/>
                  <Revenue/>
                  <GroupingAttributes>
                    <GroupingAttribute code="resource_class_id" value="INFRA"/>
                  </GroupingAttributes>
                  <CustomInformation>
                    <ColumnValue name="partition_code">NIKU.ROOT</ColumnValue>
                  </CustomInformation>
                </Detail>
                <Detail>
                  <Cost/>
                  <Units/>
                  <Revenue/>
                  <GroupingAttributes>
                    <GroupingAttribute code="resource_class_id" value="SOFT"/>
                  </GroupingAttributes>
                  <CustomInformation>
                    <ColumnValue name="partition_code">NIKU.ROOT</ColumnValue>
                  </CustomInformation>
                </Detail>
                <Detail>
                  <Cost/>
                  <Units/>
                  <Revenue/>
                  <GroupingAttributes>
                    <GroupingAttribute code="resource_class_id" value="NOASIG"/>
                  </GroupingAttributes>
                  <CustomInformation>
                    <ColumnValue name="partition_code">NIKU.ROOT</ColumnValue>
                  </CustomInformation>
                </Detail>
              </Details>
              <CustomInformation>
                <ColumnValue name="partition_code">NIKU.ROOT</ColumnValue>
                <ColumnValue name="map_bucreadorpmo">false</ColumnValue>
              </CustomInformation>
            </CostPlan>
          </CostPlans>
        </NikuDataBus>
      </gel:parse>
      <!-- Fin Parseo del XOG a escribir -->
      <gel:set asString="true" select="$x_escritura" var="v_escritura"/>
      <gel:log>XOG a escribir: ${v_escritura}</gel:log>
      <gel:log>Comienza la escritura, se inicia sesión</gel:log>
      <!-- Inicio de Login en XOG -->
      <soap:invoke endpoint="${v_XOGURL}/niku/xog" var="auth">
        <soap:message>
          <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xog="http://www.niku.com/xog">
            <soapenv:Header/>
            <soapenv:Body>
              <xog:Login>
                <xog:Username>${userXOG}</xog:Username>
                <xog:Password>${passXOG}</xog:Password>
              </xog:Login>
            </soapenv:Body>
          </soapenv:Envelope>
        </soap:message>
      </soap:invoke>
      <!-- Fin de Login en XOG -->
      <gel:log>Inicio de sesión completo, se comprueba que haya sido correcto</gel:log>
      <!-- Inicio comprobación Login correcto y carga de XOG en caso positivo-->
      <gel:set asString="true" select="$auth/SOAP-ENV:Envelope/SOAP-ENV:Body/xog:SessionID/text()" var="v_sessionID"/>
      <core:choose>
        <!-- Inicio caso Login Incorrecto -->
        <core:when test="${v_sessionID == null}">
          <gel:log category="XOG" level="ERROR">No se ha podido iniciar sesión en XOG</gel:log>
        </core:when>
        <!-- Fin caso Login Incorrecto -->
        <!-- Inicio caso Login Correcto -->
        <core:otherwise>
          <gel:log category="XOG" level="INFO">Se ha iniciado sesión en XOG, se procede a invocar el XOG</gel:log>
          <!-- Inicio invocación XOG -->
          <soap:invoke endpoint="${v_XOGURL}/niku/xog" var="x_runresult">
            <soap:message>
              <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xog="http://www.niku.com/xog">
                <soapenv:Header>
                  <xog:Auth>
                    <xog:SessionID>${v_sessionID}</xog:SessionID>
                  </xog:Auth>
                </soapenv:Header>
                <soapenv:Body>
                  <gel:include select="$x_escritura"/>
                </soapenv:Body>
              </soapenv:Envelope>
            </soap:message>
          </soap:invoke>
          <!-- Fin invocación XOG -->
          <gel:log category="XOG" level="INFO">Termina la invocación del XOG.</gel:log>
          <gel:set asString="true" select="$x_runresult" var="v_runresult"/>
          <gel:log>Resultado del XOG: ${v_runresult}</gel:log>