Example 3 Restricts Status Change if the Operational Attributes of Affected Items Have No Values

You can write a Groovy script that restricts status change of a change order from interim approval1 to interim approval2 if the operational attribute of affected items don't have values.

In the change exit criteria for the Interim Approval 1 to Interim Approval2 phase, the script should check if the operational attributes have been filled in for the affected items. If the operational attributes don't have values, it should restrict the promotion to interim approval2.

Here are the configuration steps:
  1. Create a web service.
    1. Web service: GetAffectedItem

      URL:

      https://hostname/fscmRestApi/resoucres/11.13.18.05/productChangeOrders/##changedId##/child/AffectedObject

    2. Web service: GetAIAttributes

      URL:

      https://hostname/fscmRestApi/resources/11.13.8.05/productChangeOrdersV2/##changeId##//child/changeOrderAffectedObject/##itemId##/child/changeOrderAffectedItem
  2. Create a global function in Application Composer.
    Note:
    • This global function is provided only as a reference. Performance may be impacted depending on the number of items and the number of attributes which you are validating.
    • REST API doesn’t support all the operational attributes. See the SCM REST API documentation for details.
    • Trigger: Item Rules
    • Object: Commercialization Change Order
    • Tab: Item
    • Application Composer Navigation: Change Order ->Global Function Criteria at Interim Approval
    • Function:
      def itemId = ""
      def rtrnVal = true
        println(changeId)
        def aitems = adf.webServices.GetAffectedItem.GET(changeId)
        def ailnk = aitems["items"]
        for(affectedItem in ailnk)
        {
          println("In the loop")
          def links = affectedItem["links"]
          for(lnk in links)
          {
         if(lnk["rel"].toString() =="self" && lnk["name"].toString()=="AffectedObject")
          {
            println(lnk["href"])
            itemId = String.valueOf(lnk["href"].toString().replace("https://hostname/fscmRestApi/resources/11.13.18.05/productChangeOrders/"+changeId+"/child/AffectedObject/",""))
            println(itemId)
            //Invoke affected item REST service
            def affectedItems = adf.webServices.GetAIAttributes.GET(changeId, itemId)
            def aiAttr = affectedItems["items"]
            for(attr in aiAttr)
            {
              println(attr["EnforceShipToLocationValue"])
              if(attr["EnforceShipToLocationValue"]== null)
              {
                rtrnVal=false
              }
            }
          }
        }
        }
      return rtrnVal
  3. Set up Item Rule in the Rules tab of the Edit Rule Set page of the change order.

    InvokeGlobalFunction("validateAttrVal", [ChangeHeader].[Change Header Main].[Change ID])

    Here's how you define a rule in the Edit Rule Set page

    This image shows how the rules can be configured in global functions
  4. Change order criteria: Define the criteria in the Workflow tab of the Edit Change Order Type page.

Add the M1ORGCCO rule as the exit criteria for interim approval status.

This image displays the exit criteria