Inside Activate
...
How To
Track Order Only Services
9 min
some services need to be ordered and recorded , but do not require ongoing lifecycle management after fulfilment in these cases, activate supports order only services that immediately end themselves , allowing the order to be tracked without leaving an active service instance behind this approach is commonly used for physical or consumable items where return, expiry, or revocation is not relevant, but audit and reporting of the order itself is still valuable order only services with immediate end behaviour order only services are designed to trigger fulfilment without behaving like long lived services when configured correctly, the service instance is created for tracking purposes and then immediately ended as part of the order process this allows you to record that the service was ordered run fulfilment processes as normal avoid cluttering user records with inactive services retain accurate reporting and audit history when to use this approach use this pattern when the service represents a one off item there is no concept of return, expiry, or revocation the order itself must be auditable or reportable the service should not appear as active for the user common examples include mouse pads peripherals printed materials welcome or starter items how the behaviour works when an order only service is requested the service order runs as normal the service instance is saved so the order can be tracked the service instance is immediately ended as part of the order process from a configuration perspective, this happens entirely within the order process , without requiring the service to behave like a managed lifecycle service this behaviour applies only to order only services standard services continue to follow their normal lifecycle rules implementation overview this pattern consists of an order only service an order process attached to that service a script in the order process that immediately ends the service instance after saving it service configuration the service must be configured as order only this ensures the service does not remain active after fulfilment the lifecycle is controlled by the order process the service instance exists only for tracking and reporting order process configuration attach an order process to the service this process is responsible for handling fulfilment saving the service instance ending the service instance immediately once recorded the script below must be executed as part of this order process order process script the following script processes the services included in the order, saves any new order only service instances, and immediately ends them this script can be found at //tasks/services/order/orderonlyscript out of the box 8 2 version this version is for 8 2 and above using system; using system xml; using innovation activate; class script scriptbase { 	public void main() 	{ 	 serviceinstancecollection services = new serviceinstancecollection(null); 	 foreach (xmlelement n in job arguments selectnodes("services/ ")) 	 { 	 serviceinstance srv = serviceinstance getfromxml(n); 	 if (srv == null) continue; 	 	 	 if(srv id>0) continue; // already created 	 if (srv status == provisioningobject provisioningobjectstatus published && srv flags hasflag(serviceinstance serviceflags orderonly)) 	 { 	 srv status = provisioningobject provisioningobjectstatus deleted; 	 srv setinfo(); 	 xmlvalue set(n, "id", srv id tostring()); 	 } 	 } 	} } 8 1 version this version applies to 8 1 and below using system; using system xml; using innovation activate; class script scriptbase { 	public void main() 	{ 	 serviceinstancecollection services = new serviceinstancecollection(null); 	 foreach (xmlelement n in job arguments selectnodes("services/ ")) 	 { 	 serviceinstance srv = serviceinstance getfromxml(n); 	 if (srv == null) continue; 	 	 	 if(srv id>0) continue; // already created 	 if (srv status == provisioningobject provisioningobjectstatus published && srv flags hasflag(serviceinstance serviceflags orderonly)) 	 { 	 srv setinfo(); 	 srv delete(job, false); 	 xmlvalue set(n, "id", srv id tostring()); 	 } 	 } 	} } this script ensures that the order is fully recorded the service instance does not remain active the order can be audited and reported on reporting behaviour although the service instance is immediately ended the order is still visible in service history reports can show when the service was ordered and by whom the service does not appear as active for the user this makes the approach suitable for consumable or physical item reporting audit trails cost or chargeback reporting version notes in activate 8 1, the recommended approach is to save the service instance and immediately end it in the order process in activate 8 2 and later, order only services also support being ended at creation time for maximum compatibility, using the order process script to end the service instance works consistently across versions summary order only services with immediate end behaviour allow you to trigger fulfilment workflows maintain clean user service records retain accurate order history they are ideal for scenarios where tracking the order matters, but tracking the service lifecycle does not