Creation of asset from catalog item?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-06-2018 10:42 PM
I have a catalog item and after ordering the catalog item and after running the requested item's workflow, the catalog item should become an asset. Can anyone please explain me how to do it?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-06-2018 11:43 PM
Hi Harminder,
After request fulfillment of your requested item execute script in the requested item workflow to create asset record based on your business logic.
For executing the script make use of "Run Script" workflow activity.
Mark answer as correct/helpful if it resolves your issue.
Best Regards,
Rajesh M.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-07-2018 12:03 AM
Ya thats fine but how to map a catalog item to an asset?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-07-2018 12:36 AM
In asset form we have a field by the name Request Line. mapping between asset and Requested item can be established there.
Hope this helps.
Best Regards,
Rajesh M.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-07-2018 01:49 AM
We've done a similar solution where we have created a mapping table. In our case we've got the mapping between Product Model and the Catalog Item.
From the product model we'll get which asset table the model is related to (from the Model Category field).
With this information you can create an asset in the correct asset table by using a run script in the workflow.
We query this custom table to find out what Product Model is related to the Catalog Item. When we know which Product Model it is we get the asset table from the Model Category and then insert an asset to this table.
If you don't want to get the asset table from the Product Model you can always add an extra field for this in your mapping table.
With these two fields you have all info needed to generate an asset. You do it the same way as the solution above with a run script.
- Make a glide record to the mapping table
- Use the Asset table information from the mapping table to insert a new record into the correct asset table
Here is a bit of sample code you could use, you need to figure out how to get the correct model category as well, it could be more than one for a product model so it's up to you which approach you take
var gr = new GlideRecord('your_mapping_table');
gr.addQuery('u_catalog_item', current.getValue('cat_item));
gr.query();
if(gr.next()){
var assetClass = gr.getValue('u_asset_table');
if(assetClass){
var asset = new GlideRecord(assetClass);
asset.initialize();
asset.setValue('request_line', current.getUniqueValue()); //This will insert the RITM to the Request Line field
asset.setValue('asset_tag', 'your_asset_number');
asset.setValue('model', gr.getValue('u_product_model'));
asset.insert();
}
else{
gs.log('No Asset Class was found, asset hasn't been created')
}
}