The Shopping workflow extends the default Shopping Progress Provider feature by allowing VBScripts to be executed asynchronously during workflow transitions so that Shopping can communicate progress about the application request to third-party applications.

 Shopping callbacks

Two types of workflow integration can be configured:

  • Shopping request workflow for applications
  • Shopping OS Deployment workflow

Configuring Shopping request workflow integration

Workflow Integration is managed from the Shopping Admin Console. To configure workflow integration:

  1. In the Shopping Admin Console, choose Settings node.
    Configuring workflow integration
  2. Expand the Workflow Integration settings – there are 8 parameters for Workflow Integration:
    • the first 6 parameters are for defining the location and names of the workflow scripts.
    • MaxWorkflowRetries is the retry count for failed scripts (default value is 3) but can be modified on-demand.
    • WorkflowIntegrationMode is the nature of the integration. Choose from one of the following:

      Value1. New request2. Approval update3. Approval process complete4. Application request deployed5. Installation process completed6. Application request cancelled
      Off (Default)(error)(error)(error)(error)(error)(error)
      BasicApproval(tick)(error)(tick)(error)(error)(tick)
      FullApproval(tick)(tick)(tick)(error)(error)(tick)
      BasicApprovalAndConfigMgr(tick)(error)(tick)(error)(tick)(tick)
      FullApprovalAndConfigMgr(tick)(tick)(tick)(tick)(tick)(tick)
  3. Click Save.

    An IIS restart is required for the changes to take effect.

Other workflow configurations to consider are:

ConfigurationNotes
Workflow script location

The name and location for each VBscript file is defined in the Workflow Integration table under Shopping Admin Console settings.

Timeout for VBscripts files

The default timeout for VBscripts to execute is defined in the Central service table under Shopping Admin Console settings.

Location of temporary files

The environment TEMP variable used for the temporary copy of the VBscript files is defined in the Central service table under Shopping Admin Console settings. 

When a file needs to be executed, the Central service makes a temporary copy in this location folder, with its name is appended with the RequestRef.  It is then parsed so that its variables are replaced with values, then executed and deleted.

Interval for pending requests

The default interval for polling requests is defined in the Central service table under Shopping Admin Console settings.

The central service must be restarted following any updates. You can do this from the command line or in the ShoppingCentral registry.

An overview of the Shopping request workflow is provided in the below diagram. This is for applications only, the OS deployment workflow is outlined further below.

The numbers in blue boxes are for ease of reference only. The numbered iems in red refer to the workflow integration points listed in the table above. The Mail items in purple text refer to emails sent at each stage, and are decribed further in Localizing Shopping.

The Shopping request workflow

Configuring the OS deployment workflow

OS deployment workflow

We've introduced a new workflow feature from Shopping v4 – the OS deployment (OSD) workflow. It differs from the Shopping request workflow for applications in that it is self-service with no approval.  Furthermore, it can be scheduled to be delivered at a future date and time (depending on the licensing model) and at a time convenient to the shopper.

Shoppers can request an OS deployment by using the OSD wizard on the Shopping home page. Progress is saved for that shopper until the wizard is complete.

When the request for an OS deployment is due, the system automatically submits an order for ConfigMgr to process. OSD workflow transitions have events associated with them and for each of event, there is an associated XML file describing the status of the transition.

The XML contains the following sections:

    • <RequestItem></RequestItem> – the OSD request item (defined in Admin Console)

    • <DeploymentItem.></DeploymentItem> – the shopper's preferences for the deployment, for example scheduling, application re-installs, etc.
    • <Order></Order> – the order entity (tb_CompletedOrder) that is created to track the progress of the deployment
    • <User></User> – the shopper who requested the migration or in the case of the OSD confirmation, the shopper who confirmed the migration
    • <Machine></Machine> – the machine on which the OS deployment is for

View the XML files

  1. In the Shopping Admin Console, choose the Settings node.
  2. Expand the OS Deployment settings.
  3. Update the OS Deployment Workflow Integration Enabled setting from False to True.
  4. Click Save.
  5. Restart the central service from the command-line or in the ShoppingCentral registry.

Application references

Shopping applications are set up in the Shopping Admin Console. You may also want to define a unique Application Ref for each Application you will be accessing in your custom interface. This information is not mandatory, but helps to identify Shopping applications using a unique ID that is meaningful to the calling application. For example this could be an identifier from a third-party purchasing, inventory or license management system.

Application Ref must be unique.  It is best practice to use an appropriate format that reflects all the reasons for having a unique reference for each application.  For example, is the application ConfigMgr or non-ConfigMgr, supported OS, global or regional. 
Application references

Workflow integration files

These integration files are used to make calls to third-party APIs, update the database or write a text file with data from each stage of the Shopping workflow. There are currently 6 application templates (one for each stage of the workflow) as well as 5 OS deployment templates located in the WorkflowIntegration folder for the Shopping Central Service:

Integration fileWorkflow typeDescription
ApplicationRequested.vbsApplicationCalled when a new application is requested (including requests made by administrators on behalf of others)
ApprovalUpdate.vbsApplicationCalled when approval and license checks are completed for an approval application for the following conditions:
    • License check OK – moving onto next Approver
    • License threshold reached – moving onto next Approver
    • License Max reached – held at current Approver (also applies to any/single chain case)
ApprovalProcessCompleted.vbsApplicationCalled at the end of the approval process irrespective of whether or not approval is enabled for an application for the following conditions:
    • Application approved
    • License check OK (including approved by virtue of having no Approvers)
    • Application rejected
ApplicationRequestDeployed.vbsApplicationOnly applicable to SMS/SCCM applications and is called when a request to SMS/SCCM is deployed.
InstallationProcessCompleted.vbsApplicationCalled when the SMS/SCCM installation process is completed.
ApplicationRequestCancelled.vbsApplicationCalled when an existing application request is cancelled.
OsdItemCancelled.vbsOSDCalled when an OSD event is cancelled.
OsdItemChanged.vbsOSDCalled when there are changes to an OSD event which hasn't been submitted.
OsdItemCompleted.vbsOSDCalled when an OSD event is completed.
OsdItemCreated.vbsOSDCalled when an OSD event is created.
OsdItemSubmitted.vbsOSDCalled when an OSD event is submitted.

The installed versions of these files simply creates a text file with common data. You will need to customize them to make them useful. Take a look at the Workflow integration parameters to see the extent of the customization.

The parameter to make note of is %FINALSTAGE%. It indicates if the executed script is the last one for the active workflow dependent on the integration mode.

If you repair the Shopping installation with the Shopping MSI, you will lose your customizations. Back-up your customizations before you do this.

Application script processing

Workflow stage details are written to the tb_WorkflowIntegration_Requests which maintains a strict ordering of the workflow requests. It also holds status information for the associated integration scripts. The central service polls this table every 10 seconds for pending requests and performs the following actions:

  • Reads the workflow integration request including workflow stage and request ref
  • Loads the scrpit associated with that particular workflow stage
  • Substitutes script parameters with data for the request details
  • Executes the script
  • Waits for the script to return with a status code or timeout
  • Updates the state of workflow request in the table

Workflow status in this table may be one of the following:

  • Pending – request is yet to be processed
  • Retry – the script was executed and either returned an error or timed out (with the process successfully terminated) and has retries remaining. The retry takes place when the central service retry job executes.
  • Failed – the script was executed and either returned an error with no retries remaining or timed out with the process still running.
  • Suspended – scripts with an overflow step or sequence are being retried.
  • Complete – request is processed successfully. If this is the last step for the application, all records with the same request reference are removed from the database.

OSD script processing

OSD event processor listenerThe Shopping central service runs the Event Processor listener that continuously polls for OSD events every 5 minutes. When it finds an event, it looks up the name of the event and locates a.vbs file of the same name as the event in C:\Program Files (x86)\1E\Shopping\CentralService\WorkflowIntegration.

The Event Processor listener creates a temporary file on disk, injects the event XML into it and executes the .vbs file, passing in the path to the event data file.

The location of the temporary files is specified by the Shopping Admin Console Central Service setting Script Temp Path.  By default this is  C:\ProgramData\1E\ShoppingCentral\temp.  The Shopping Central service account must have admin rights to this location.

The temporary file has the same name as the template appended with the RequestRef GUID. If the execution fails (return code 1) a new row with the return code, the standard error and standard output of the script is created in the EventProcessingResult table (to help Shopping administrators to troubleshoot non-delivered events).

The event is retried until the retry count is exhausted whereby the event is set to Failed. This event is ignored until its status is set to Pending by the Shopping administrator. The event is set to Complete when the script is successfully executed. If no corresponding .vbs file is found, the event is considered to be processed and its state is updated to Complete.

OSD databasbase schema

OSD database schemaOSD event sources are stored in the tb_DomainEventSource table where:

  • Name is the name of the source. For OSD the name is OsDeployment
  • Reference is a unique identifier that refers to the OSD order. The reference should be used by external systems to refer back to shopping orders. This column has same value as those in tb_CompletedOrder and tb_OsdWizard.

OSD events are stored in tb_DomainEvents table and contain an XML document that represents a snapshot of the particular OSD item where:

  • Timestamp is the date and time a particular event happened and is used to determine the order in which the events are getting processed
  • Name is the name of the event
  • Sequence is the order in which events have happened for a particular event source
  • DomainEventSourceId is the ID of the source of the event
  • State refers to the event delivery status
  • Data is an XML document with the state of the OSD and its associated values

The results of integration scripts execution are stored in tb_EventProcessingResult where:

  • DomainEventID is the ID of the event this record is linked to
  • Timestamp the date and time the script was executed
  • ReturnCode is the return code for the script
  • ResultData in case of a script error, this is the captured standard output and standard error to help troubleshooting efforts

When the OSD workflow completes, the Event Processor deletes all the events and results associated with the order.

OSD integration XML files

Each workflow transition has an event associated with it and for each event there is a corresponding XML file that details the status for a particular transition. The XML files contain the following sections:

  • <RequestItem></RequestItem> – the OSD request item or application that is defined in Admin Console
  • <DeploymentItem> </DeploymentItem> – the user preferences for the deployment, for example scheduling, application re-installs, etc.
  • <Order></Order> – the order entity (tb_CompletedOrder) created to track the progress of the deployment
  • <User></User> – the user who performed the action
  • <Machine> </Machine> – the machine the OS deployment is for

Sample item created XML

OSD item Created
<OsdItemCreated>
  <DeploymentItem>
    <DateCreated>2011-07-04T11:20:04.163</DateCreated>
    <DateModified>2011-07-04T11:20:17.2394142Z</DateModified>
    <IsScheduledImmediately>false</IsScheduledImmediately>
    <ScheduledMigrationDateTime>2011-07-04T21:00:00</ScheduledMigrationDateTime>
    <HasConfirmedBackup>true</HasConfirmedBackup>
    <RequestRef>823290ca-7279-4bda-9ea4-81aee40e17c2</RequestRef>
    <ReInstallApps />
    <NewApps />
  </DeploymentItem>
  <RequestItem>
    <Name>Windows 7</Name>
    <RequestItemType>OSD</RequestItemType>
    <Description />
    <IsConfigMgrItem>true</IsConfigMgrItem>
    <Cost>0.0000</Cost>
    <ApplicationRef />
    <ConfigMgrCollectionId>DEV00048</ConfigMgrCollectionId>
    <ConfigMgrCollectionName>OS Deployments</ConfigMgrCollectionName>
    <AdvertId>DEV2001B</AdvertId>
    <PrepackagedItems />
  </RequestItem>
  <User>
    <UserAccount>DEV\shopper</UserAccount>
    <UserEmail>shopper@dev.local</UserEmail>
    <FullName>shopper</FullName>
    <ManagerAccount>DEV\manager</ManagerAccount>
    <ManagerEmail />
    <ManagerFullName>manager</ManagerFullName>
    <UserLanguage>en-US</UserLanguage>
  </User>
  <Machine>
    <MachineName>DEV-W7X64</MachineName>
    <DomainName>DEV</DomainName>
    <ConfigMgrGuid>GUID:9119DC3A-31B7-4C99-AD42-02EB825C81DE</ConfigMgrGuid>
    <IsObsolete>false</IsObsolete>
    <SiteCode>DEV</SiteCode>
    <TimeZone>60</TimeZone>
  </Machine>
</OsdItemCreated>

Sample event changed XML

OSDItemChanged.xml
<OsdItemChanged>
  <DeploymentItem>
    <DateCreated>2011-07-04T11:20:04.163</DateCreated>
    <DateModified>2011-07-04T11:20:30.0802246Z</DateModified>
    <IsScheduledImmediately>false</IsScheduledImmediately>
    <ScheduledMigrationDateTime>2011-07-04T22:00:00</ScheduledMigrationDateTime>
    <HasConfirmedBackup>true</HasConfirmedBackup>
    <RequestRef>823290ca-7279-4bda-9ea4-81aee40e17c2</RequestRef>
    <ReInstallApps />
    <NewApps />
  </DeploymentItem>
  <User>
    <UserAccount>DEV\shopper</UserAccount>
    <UserEmail>shopper@dev.local</UserEmail>
    <FullName>shopper</FullName>
    <ManagerAccount>DEV\manager</ManagerAccount>
    <ManagerEmail />
    <ManagerFullName>manager</ManagerFullName>
    <UserLanguage>en-US</UserLanguage>
  </User>
  <Machine>
    <MachineName>DEV-W7X64</MachineName>
    <DomainName>DEV</DomainName>
    <ConfigMgrGuid>GUID:9119DC3A-31B7-4C99-AD42-02EB825C81DE</ConfigMgrGuid>
    <IsObsolete>false</IsObsolete>
    <0SiteCode>DEV</SiteCode>
    <TimeZone>60</TimeZone>
  </Machine>
</OsdItemChanged>


Sample event cancelled XML

OSDItemCancelled.xml
<OsdItemCancelled>
  <RequestItem>
    <Name>Windows 7</Name>
    <RequestItemType>OSD</RequestItemType>
    <Description />
    <IsConfigMgrItem>true</IsConfigMgrItem>
    <Cost>0.0000</Cost>
    <ApplicationRef />
    <ConfigMgrCollectionId>DEV00048</ConfigMgrCollectionId>
    <ConfigMgrCollectionName>OS Deployments</ConfigMgrCollectionName>
    <AdvertId>DEV2001B</AdvertId>
    <PrepackagedItems />
  </RequestItem>
  <DeploymentItem>
    <DateCreated>2011-07-04T11:20:04.163</DateCreated>
    <DateModified>2011-07-04T11:20:30.08</DateModified>
    <IsScheduledImmediately>false</IsScheduledImmediately>
    <ScheduledMigrationDateTime>2011-07-04T22:00:00</ScheduledMigrationDateTime>
    <HasConfirmedBackup>true</HasConfirmedBackup>
    <RequestRef>823290ca-7279-4bda-9ea4-81aee40e17c2</RequestRef>
    <ReInstallApps />
    <NewApps />
  </DeploymentItem>
  <User>
    <UserAccount>DEV\shopper</UserAccount>
    <UserEmail>shopper@dev.local</UserEmail>
    <FullName>shopper</FullName>
    <ManagerAccount>DEV\manager</ManagerAccount>
    <ManagerEmail />
    <ManagerFullName>manager</ManagerFullName>
    <UserLanguage>en-US</UserLanguage>
  </User>
  <Machine>
    <MachineName>DEV-W7X64</MachineName>
    <DomainName>DEV</DomainName>
    <ConfigMgrGuid>GUID:9119DC3A-31B7-4C99-AD42-02EB825C81DE</ConfigMgrGuid>
    <IsObsolete>false</IsObsolete>
    <SiteCode>DEV</SiteCode>
    <TimeZone>60</TimeZone>
  </Machine>
  <CancellingUser>
    <UserAccount>DEV\shopper</UserAccount>
    <UserEmail>shopper@dev.local</UserEmail>
    <FullName>shopper</FullName>
    <ManagerAccount>DEV\manager</ManagerAccount>
    <ManagerEmail />
    <ManagerFullName>manager</ManagerFullName>
    <UserLanguage>en-US</UserLanguage>
  </CancellingUser>
</OsdItemCancelled>

Sample event submitted XML

OSDItemSubmitted.xml
<OsdItemSubmitted>
  <RequestItem>
    <Name>Windows7</Name>
    <RequestItemType>OSD</RequestItemType>
    <Description />
    <IsConfigMgrItem>true</IsConfigMgrItem>
    <Cost>0.0000</Cost>
    <ApplicationRef />
    <ConfigMgrCollectionId>00100029</ConfigMgrCollectionId>
    <ConfigMgrCollectionName>001 - 00100008 - Per-system unattended</ConfigMgrCollectionName>
    <AdvertId>00120013</AdvertId>
    <PrepackagedItems />
  </RequestItem>
  <DeploymentItem>
    <DateCreated>2011-08-23T09:09:32.54</DateCreated>
    <DateModified>2011-08-23T09:09:42.093</DateModified>
    <IsScheduledImmediately>true</IsScheduledImmediately>
    <ScheduledMigrationDateTime>2011-08-23T10:00:00</ScheduledMigrationDateTime>
    <HasConfirmedBackup>true</HasConfirmedBackup>
    <RequestRef>1f58b8e4-7dcd-497f-957f-426784d5faaa</RequestRef>
    <ReInstallApps />
    <NewApps />
  </DeploymentItem>
  <Order>
    <ShopperComments />
    <RequestedTimestamp>2011-08-23T09:10:18.9480005Z</RequestedTimestamp>
    <CompletedTimestamp>2011-08-23T09:10:18.9480005Z</CompletedTimestamp>
    <PackageId />
    <ProgramName />
    <DeliveryStatus>0</DeliveryStatus>
    <ScheduledTime />
    <RequestRef>1f58b8e4-7dcd-497f-957f-426784d5faaa</RequestRef>
    <DateInstalled />
    <DateUninstalled />
    <OrderType>I</OrderType>
  </Order>
  <User>
    <UserAccount>LAB006\u2</UserAccount>
    <UserEmail>U2@lab006.local</UserEmail>
    <FullName>u2</FullName>
    <ManagerAccount>LAB006\manager2</ManagerAccount>
    <ManagerEmail>manager2@lab006.local</ManagerEmail>
    <ManagerFullName>manager2</ManagerFullName>
    <UserLanguage>en-US</UserLanguage>
  </User>
  <Machine>
    <MachineName>LAB006003</MachineName>
    <DomainName>LAB006</DomainName>
    <ConfigMgrGuid>GUID:5084FF9D-EB84-43F5-B031-639E700C0056</ConfigMgrGuid>
    <IsObsolete>false</IsObsolete>
    <SiteCode>001</SiteCode>
    <TimeZone>60</TimeZone>
  </Machine>
</OsdItemSubmitted>

Sample event completed XML

OSDItemSubmitted.xml
<OsdItemCompleted>
  <RequestItem>
    <Name>Windows7</Name>
    <RequestItemType>OSD</RequestItemType>
    <Description />
    <IsConfigMgrItem>true</IsConfigMgrItem>
    <Cost>0.0000</Cost>
    <ApplicationRef />
    <ConfigMgrCollectionId>00100029</ConfigMgrCollectionId>
    <ConfigMgrCollectionName>001 - 00100008 - Per-system unattended</ConfigMgrCollectionName>
    <AdvertId>00120013</AdvertId>
    <PrepackagedItems />
  </RequestItem>
  <DeploymentItem>
    <DateCreated>2011-08-23T09:09:32.54</DateCreated>
    <DateModified>2011-08-23T09:09:42.093</DateModified>
    <IsScheduledImmediately>true</IsScheduledImmediately>
    <ScheduledMigrationDateTime>2011-08-23T10:00:00</ScheduledMigrationDateTime>
    <HasConfirmedBackup>true</HasConfirmedBackup>
    <RequestRef>1f58b8e4-7dcd-497f-957f-426784d5faaa</RequestRef>
    <ReInstallApps />
    <NewApps />
  </DeploymentItem>
  <Order>
    <ShopperComments />
    <RequestedTimestamp>2011-08-23T09:10:18.947</RequestedTimestamp>
    <CompletedTimestamp>2011-08-23T09:10:18.947</CompletedTimestamp>
    <PackageId />
    <ProgramName />
    <DeliveryStatus>1</DeliveryStatus>
    <ScheduledTime />
    <RequestRef>1f58b8e4-7dcd-497f-957f-426784d5faaa</RequestRef>
    <DateInstalled>2011-08-23T09:12:08</DateInstalled>
    <DateUninstalled />
    <OrderType>I</OrderType>
  </Order>
  <User>
    <UserAccount>LAB006\u2</UserAccount>
    <UserEmail>U2@lab006.local</UserEmail>
    <FullName>u2</FullName>
    <ManagerAccount>LAB006\manager2</ManagerAccount>
    <ManagerEmail>manager2@lab006.local</ManagerEmail>
    <ManagerFullName>manager2</ManagerFullName>
    <UserLanguage>en-US</UserLanguage>
  </User>
  <Machine>
    <MachineName>LAB006003</MachineName>
    <DomainName>LAB006</DomainName>
    <ConfigMgrGuid>GUID:5084FF9D-EB84-43F5-B031-639E700C0056</ConfigMgrGuid>
    <IsObsolete>false</IsObsolete>
    <SiteCode>001</SiteCode>
    <TimeZone>60</TimeZone>
  </Machine>
</OsdItemCompleted>

An application request example

What we're going to do is to show you how to customize ApplicationRequested.vbs  to create a ticket using the TicketManagement:CreateTicket method.

This method takes TicketID (the Request Ref) and CreateDetailText parameters. <Domain\Account> and <Password> are the user credentials of the Shopping requester.

ApplicationRequestedt.vbs
Option Explicit

Dim xmlhttp
set xmlhttp = CreateObject("MSXML2.XMLHTTP")
 
Dim request
Dim CreateDetailText
Dim ReturnCode
ReturnCode = 0

CreateDetailText = "A request for Application %APPLICATION% (%THIRDPARTYAPPREF%)" &_
"was made on %MACHINENAME% by %FULLNAME% " &_
" at UTC Date %WORKFLOWSTAGEUTCDATE%" 
  
request = "<?xml version='1.0' encoding='utf-8'?>" &_
"    <soap12:Envelope xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:soap12='http://www.w3.org/2003/05/soap-envelope'> " &_
"      <soap12:Body> " &_
"       <CreateTicket xmlns='http://ShoppingV3APITest.com/'> " &_
"         <ticketId>%THIRDPARTYREQUESTREF%</ticketId> " &_
"         <createDetail>" & CreateDetailText & "</createDetail>" &_
"       </CreateTicket> " &_
"      </soap12:Body>  " &_
"    </soap12:Envelope> " 
   

xmlhttp.open "POST", "http://localhost/TicketSystem/TicketManagementx.asmx", False, "<Domain\Account> ", "<Password> "
xmlhttp.setRequestHeader "Content-type", "text/xml; charset=utf-8"   
xmlhttp.Send(request)
if (xmlhttp.StatusText="OK") Then
    ReturnCode = 0
else
    ReturnCode = 1
End If

' Quit and return code
WScript.Quit(ReturnCode)

This is result of the ApplicationRequestedt.vbs script when the workflow parses it:

ApplicationRequestedt.vbs
Option Explicit

Dim xmlhttp
set xmlhttp = CreateObject("MSXML2.XMLHTTP")
 
Dim request
Dim CreateDetailText
Dim ReturnCode
ReturnCode = 0

CreateDetailText = "A request for Application TESTAPPLICATION (APP2667)" &_
"was made on ACMEDVMKS008 by Simon Chautma" &_
" at UTC Date 08/09/2010 20:37:02" 
  
request = "<?xml version='1.0' encoding='utf-8'?>" &_
"    <soap12:Envelope xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:soap12='http://www.w3.org/2003/05/soap-envelope'> " &_
"      <soap12:Body> " &_
"       <CreateTicket xmlns='http://ShoppingV3APITest.com/'> " &_
"         <ticketId>6954ab7c-8217-43ea-b130-ea4035862b03</ticketId> " &_
"         <createDetail>" & CreateDetailText & "</createDetail>" &_
"       </CreateTicket> " &_
"      </soap12:Body>  " &_
"    </soap12:Envelope> " 
   

xmlhttp.open "POST", "http://localhost/TicketSystem/TicketManagementx.asmx", False, "<Domain\Account> ", "<Password> "
xmlhttp.setRequestHeader "Content-type", "text/xml; charset=utf-8"   
xmlhttp.Send(request)
if (xmlhttp.StatusText="OK") Then
    ReturnCode = 0
else
    ReturnCode = 1
End If

' Quit and return code
WScript.Quit(ReturnCode)

Notice how the script uses the WScript.Quit method to pass a return code for the status of the execution. All workflow integration scripts return 0 on success or 1 on error.

In this example, we are able to use the TicketID in the create method. However, it the thrid-party application does not support this, we can replace the Shopping Request ref with a ticket ID returned from the third-party application (this ID must be unique in the Shopping database) by calling the ShoppingAPI2 UndateRequestRef method from ApplicationRequestedt.vbs.

And if you wanted to use ApplicationRequestedt.vbs to insert a record into a database table, here's how to do it. In this example, we're going to insert a record in the NewRequests table in the TicketingSystem database.

ApplicationRequestedt.vbs
Option Explicit
Dim objConnection
Dim objCommand
Set objConnection = CreateObject("ADODB.Connection")
Set objCommand = CreateObject("ADODB.Command")
objConnection.Open _
        "Provider=SQLOLEDB;Data Source=(local);" & _
            "Trusted_Connection=Yes;Initial Catalog=TicketingSystem;"
objCommand.ActiveConnection = objConnection
objCommand.CommandText = "INSERT INTO tb_NewRequests (RequestRef,UserAccount,ApplicationName,MachineName,RequestDateUTC)" &_
"VALUES ('%THIRDPARTYREQUESTREF%','%USERACCOUNT%', '%APPLICATION%', '%MACHINENAME%','%WORKFLOWSTAGEUTCDATE%')"
objCommand.Execute
' Quit with default error code of 0
WScript.Quit

Workflow integration parameters

The summary of theparameters for each of the Shopping workflow stages and their full description is detailed below.

Application requested parameters

The application requested workflow stage uses the following parameters. Follow the link to see a description for the parameter and the template it is used in.

Approval updated parameters

The approval updated workflow stage uses the following parameters. Follow the link to see a description for the parameter and the template it is used in.

The approval completed workflow stage uses the following parameters. Follow the link to see a description for the parameter and the template it is used in.

Application request deployed parameters

The application request deployed workflow stage uses the following parameters. Follow the link to see a description for the parameter and the template it is used in.

Installation process completed parameters

The installation process completed workflow stage uses the following parameters. Follow the link to see a description for the parameter and the template it is used in.

Application cancelled parameters

The application cancelled workflow stage uses the following parameters. Follow the link to see a description for the parameter and the template it is used in.

VB Script parameters

ParameterUsed in VB scriptsDescription
%ADDITIONALNOTIFICATIONTEXT%
ApplicationRequested.vbs
ApprovalUpdate.vbs
ApprovalProcessCompleted.vbs
ApplicationRequestDeployed.vbs
InstallationProcessCompleted.vbs
The text specifying a link to a file share, for example where an application uses AD integration.
%APPLICATION%
ApplicationRequested.vbs
ApprovalUpdate.vbs
ApprovalProcessCompleted.vbs
ApplicationRequestDeployed.vbs
InstallationProcessCompleted.vbs
The display name of the application.
%APPLICATIONAPPROVED%
ApprovalProcessCompleted.vbsWhether the application is approved (0 or 1).
%APPLICATIONINSTALL%
ApplicationRequestDeployed.vbsWhether the request deployed is for an install (0 or 1).
InstallationProcessCompleted.vbsWhether the application was uninstalled (0 or 1).
%APPLICATIONREQUESTTYPE%
ApplicationRequested.vbs

The type of the application request. One of:

    • 10 – StandardInstall
    • 20 – StandardUninstall
    • 30 – AdminInstall
    • 40 – AdminCopyConfig
    • 50 – AdminReinstall
    • 60 – AdminUninstall
    • 70 – AdminUninstallDeferred
    • 90 – AutoUninstall
%APPROVALUPDATETYPE%
ApprovalUpdate.vbsThe type of the approval update. One of:
    • 20 – Approved, LicenseOK
    • 30 – Approved, LicenseThresholdReached
    • 40 – Approved, LicenseLimitReached
ApprovalProcessCompleted.vbsThe type of the approval update. One of:
    • 10 – Rejected, LicenseUnverified
    • 20 – Approved, LicenseOK
    • 30 – Approved, LicenseThresholdReached
    • 40 – Approved, LicenseLimitReached
%APPROVERCOMMENT%

ApprovalProcessCompleted.vbs
ApprovalUpdate.vbs

The comments of the Approver (blank if not applicable).
%APPROVEREMAIL%
ApprovalUpdate.vbsThe email of the Approver (blank if not applicable).
%APPROVEREMAIL%
ApprovalProcessCompleted.vbsThe full name of the next Approver (blank if not applicable).
%APPROVERFULLNAME%
ApprovalProcessCompleted.vbs
ApprovalUpdate.vbs
The full name of the Approver (blank if not applicable).
%COMMENT%
ApplicationRequested.vbs
ApprovalUpdate.vbs
ApprovalProcessCompleted.vbs
ApplicationRequestDeployed.vbs
InstallationProcessCompleted.vbs
The comment associated with the application request (blank if not applicable).
%DEPLOYDEFERRED%
ApplicationRequestDeployed.vbsWhether the deploy has been deferred to a later date.
%DESCRIPTION%
ApplicationRequested.vbs
ApprovalUpdate.vbs
ApprovalProcessCompleted.vbs
ApplicationRequestDeployed.vbs
InstallationProcessCompleted.vbs
The description of the application.
%FINALSTAGE%
ApplicationRequested.vbs
ApprovalUpdate.vbs
ApprovalProcessCompleted.vbs
ApplicationRequestDeployed.vbs
InstallationProcessCompleted.vbs
This parameter indicates if the current workflow stage being executed is the final stage script that will be executed for that particular request. Which script will be the final stage is affected mainly by the workflow integration mode and the application type.
%FULLNAME%
ApplicationRequested.vbs
ApprovalUpdate.vbs
ApprovalProcessCompleted.vbs
ApplicationRequestDeployed.vbs
InstallationProcessCompleted.vbs
The full name of the user who requested the application.
%GUID%
ApplicationRequested.vbs
ApprovalUpdate.vbs
ApprovalProcessCompleted.vbs
ApplicationRequestDeployed.vbs
InstallationProcessCompleted.vbs
The ConfigMgr client GUID for the machine on which the request was made.
%HADAPPROVERS%
ApprovalProcessCompleted.vbsWhether there were Approvers associated with the request (0 or 1).
%HASLICENSING%
ApprovalProcessCompleted.vbs
ApprovalUpdate.vbs
Whether the application has licensing (0 or 1).
%INSTALLSUCCESS%
InstallationProcessCompleted.vbsWhether the install/uninstall was successful (0 or 1).
%LICENSECOUNT%
ApprovalProcessCompleted.vbs
ApprovalUpdate.vbs
The current number of licenses used for the application.
%MACHINENAME%
ApplicationRequested.vbs
ApprovalUpdate.vbs
ApprovalProcessCompleted.vbs
ApplicationRequestDeployed.vbs
InstallationProcessCompleted.vbs
The NETBIOS name of the machine on which the request was made.
%MAXLICENSES%
ApprovalProcessCompleted.vbs
ApprovalUpdate.vbs
The max license count for the application.
%NEXTAPPROVEREMAIL%
ApprovalUpdate.vbsThe email of the next Approver (blank if not applicable).
%NEXTAPPROVERFULLNAME%
ApprovalUpdate.vbsThe full name of the next Approver (blank if not applicable).
%NONSMS%
ApplicationRequested.vbs
ApprovalUpdate.vbs
ApprovalProcessCompleted.vbs
ApplicationRequestDeployed.vbs
InstallationProcessCompleted.vbs
Whether the application is non ConfigMgr.
%PERCENTLICENSESUSED%
ApprovalProcessCompleted.vbs
ApprovalUpdate.vbs
The percentage of current licenses used for the application.
%REQUESTDEFERREDUNTIL%
ApplicationRequestDeployed.vbsThe date until the deployed has been deferred until (blank if not applicable).
%SITE%
ApplicationRequested.vbs
ApprovalUpdate.vbs
ApprovalProcessCompleted.vbs
ApplicationRequestDeployed.vbs
InstallationProcessCompleted.vbs
The ConfigMgr site code associated with the machine on which the request was made.
%SMSPACKAGEID%
ApplicationRequested.vbs
ApprovalUpdate.vbs
ApprovalProcessCompleted.vbs
ApplicationRequestDeployed.vbs
InstallationProcessCompleted.vbs
The ConfigMgr Installation PackageID of the application (blank if not applicable).
%SMSPACKAGENAME%
ApplicationRequested.vbs
ApprovalUpdate.vbs
ApprovalProcessCompleted.vbs
ApplicationRequestDeployed.vbs
InstallationProcessCompleted.vbs
The ConfigMgr Installation Package Name of the application (blank if not applicable).
%SMSPROGRAMNAME%
ApplicationRequested.vbs
ApprovalUpdate.vbs
ApprovalProcessCompleted.vbs
ApplicationRequestDeployed.vbs
InstallationProcessCompleted.vbs
The ConfigMgr Installation Program Name of the application (blank if not applicable).
%SMSUNINSTALLPACKAGEID%
ApplicationRequested.vbs
ApprovalUpdate.vbs
ApprovalProcessCompleted.vbs
ApplicationRequestDeployed.vbs
InstallationProcessCompleted.vbs
The ConfigMgr Uninstall PackageID of the application (blank if not applicable).
%SMSUNINSTALLPACKAGENAME%
ApplicationRequested.vbs
ApprovalUpdate.vbs
ApprovalProcessCompleted.vbs
ApplicationRequestDeployed.vbs
InstallationProcessCompleted.vbs
The ConfigMgr Uninstall Package Name of the application (blank if not applicable).
%SMSUNINSTALLPROGRAMNAME%
ApplicationRequested.vbs
ApprovalUpdate.vbs
ApprovalProcessCompleted.vbs
ApplicationRequestDeployed.vbs
InstallationProcessCompleted.vbs
The ConfigMgr Uninstall Program Name of the application (blank if not applicable).
%THIRDPARTYAPPREF%
ApplicationRequested.vbs
ApprovalUpdate.vbs
ApprovalProcessCompleted.vbs
ApplicationRequestDeployed.vbs
InstallationProcessCompleted.vbs
The third-party reference for the application
%THIRDPARTYREQUESTREF%
ApplicationRequested.vbs
ApprovalUpdate.vbs
ApprovalProcessCompleted.vbs
ApplicationRequestDeployed.vbs
InstallationProcessCompleted.vbs
The unique Request reference common to each stage of the workflow.
%THRESHOLD%
ApprovalProcessCompleted.vbs
ApprovalUpdate.vbs
The current license threshold setting for the application.
%UNINSTALLREASON%
ApplicationRequestDeployed.vbsThe reason for the uninstall (blank if not applicable).
%USERACCOUNT%
ApplicationRequested.vbs
ApprovalUpdate.vbs
ApprovalProcessCompleted.vbs
ApplicationRequestDeployed.vbs
InstallationProcessCompleted.vbs
The account of the user who requested the application.
%USEREMAIL%
ApplicationRequested.vbs
ApprovalUpdate.vbs
ApprovalProcessCompleted.vbs
ApplicationRequestDeployed.vbs
InstallationProcessCompleted.vbs
The email of the user who requested the application.
%WORKFLOWSTAGE%
ApplicationRequested.vbs
ApprovalUpdate.vbs
ApprovalProcessCompleted.vbs
ApplicationRequestDeployed.vbs
InstallationProcessCompleted.vbs
The workflow stage that the script corresponds to. One of:
    • 10 – ApplicationRequested
    • 20 – ApprovalUpdate
    • 30 – ApprovalProcessCompleted
    • 40 – ApplicationRequestDeployed
    • 50 – InstallationProcessCompleted
%WORKFLOWSTAGEUTCDATE%
ApplicationRequested.vbs
ApprovalUpdate.vbs
ApprovalProcessCompleted.vbs
ApplicationRequestDeployed.vbs
InstallationProcessCompleted.vbs
The date at which the workflow integration request was added to the database in UTC.