Introduction
This document intended to provide a detailed guide and examples on how to write EKL script to create new version of any object using Web service.
Version – Validated on 2022x FD01 (FP2205) & 2023x FD02 (FP2314)
Pre-requisites
Licenses – In order to execute this script successfully, user must have below licenses assigned:
Sr. No | License | Use |
|---|---|---|
1 | CSV |
|
2 | PPL |
|
3 | KDI |
|
Disclaimer: Licenses mentioned above are as per 2022x & 2023x documentation.
Example
Below is the ready use EKL script. In order to use this script, create an Knowledge Action as specified in the how to deploy section of the script.
Detail Explanation
This script can create version for one object at a time.
The supported objects are:
- Product items
- Mfg. Items
- Resource Items
- Systems and Operations
Selecting Web Service URI to get Physical ID
To get physical ID of objects, there are different web service URI's for different objects.
At the start of the code, there are strings defined for each type of objects , which contains all subtypes available in that type. For example:
set strMfgItemType = "CreateAssembly;Provide;Transform;Fasten;Installation;CreateMaterial;CreateKit;ElementaryEndItem;PreDrill;Drill;NoDrill;Cutting;Grinding;Beveling"
For selecting the correct URI as per the selected object type, "IF Else" blocks are used. Please find the section of code between below two comments in attached EKL script:
/*----Section of code to select web service URI according to object type----------------------*/ . . /*----End of: Section of code to select web service URI according to object type--------------*/
How to get Physical ID?
How to Create New version of object?
To create new version of the object, a "Post" request is sent to the webservice. A String containing details of the object to be versioned is sent as a payload.
The URI of the Web Service to create version is:
| Method | Path |
|---|---|
| Post | "/resources/v1/modeler/dslc/version/create" |
The below code shows how the payload string is constructed:
Let jsonBody(String) //Json payload to be sent
jsonBody = "{"
jsonBody = jsonBody + "\\"data\\":[{\\"id\\":\\"" + OBJPhysID + "\\","
jsonBody = jsonBody + "\\"identifier\\":\\"" + OBJPhysID + "\\","
jsonBody = jsonBody + "\\"type\\":\\""+ oCorpusInstType +"\\","
jsonBody = jsonBody + "\\"source\\": \\"https://ve4al702dsy.dsone.3ds.com:443/3DSpace\\","
jsonBody = jsonBody + "\\"relativePath\\": \\"/resources/v1/modeler/"+ oCorpusRefType +"/" + OBJPhysID + "\\""
jsonBody = jsonBody+ "}]}" Here,
- OBJPhysID: Physical ID of object retrieved in previous steps.
- oCorpusInstType: Corpus type of the instance of the object.
- oCorpusRefType: Corpus type of the Reference of the object.
(Information related to Corpus can be found here)
If the request is successful, web service returns a response containing the information of new versioned object.
The detailed code to call versioning web service can be found between below comments in the EKL Script:
/*-------SECTION TO Create New Version of Selected Object -------------*/ . . /*---- End of: SECTION TO Create New Version of Selected Object--------*/
How to deploy
In order to use this script, follow below steps:
1. Download the attached EKL scripts.
2. Create a knowledge action.
3. Copy and paste the content of attached EKL script in the newly created action.
4. Set the input arguments as mentioned in the script and click apply.
5. In the Script, in the JSON payload, change the "Source" element with your server URL.
For example:
"source": "https://ve4al702dsy.dsone.3ds.com:443/3DSpace" //For successful execution of the script, replace the highlighted part in the above line of code with your server URL.
5. Execute the script and select the input arguments.
6. Click ok.
How to create knowledge action?
References links
2022x Web Service Documentation
2023x Web Service Documentation
Author
Person of Contact - @KA
