Last active
June 1, 2025 06:48
-
-
Save NithinMahesh1/28849ea1031380a5c2596dee3e2f1598 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| * Inputs: | |
| * -this: Context Item | |
| * -Properties: | |
| * -pullType - PullType: Options are DDRBaseline, UnitNWD, Baseline, InitialBaseline, or InProgress | |
| * -isInternal - Internal method or not (if not necessary, omit all references to isInternal | |
| */ | |
| //This code grabs a Conversion Rule's ID, an Identity to run the Conversion Rule, a series of properties that need to be added, and then creates a Conversion Task based on the data provided | |
| //Set Conversion Rule ID and ConversionManager Identity ID to fit your environment | |
| string ruleID = ""; | |
| string conversionIdentityID = ""; | |
| //Query for the Conversion Rule and ConversionRuleEventTemplates | |
| //ConversionRuleEventTemplates are for post/pre conversion operations | |
| Innovator innovator = getInnovator(); | |
| Item ruleItem = innovator.newItem("ConversionRule"); | |
| ruleItem.createRelationship("ConversionRuleEventTemplate", "get"); | |
| ruleItem.setProperty("id", ruleID); | |
| ruleItem = ruleItem.apply("get"); | |
| if (ruleItem.isError()) | |
| { | |
| return ruleItem; | |
| } | |
| var publishingRule = new Aras.ConversionFramework.Models.ConversionRule() { Item = ruleItem }; | |
| var conversionManager = new Aras.ConversionFramework.Management.InnovatorConversionManager(innovator.getConnection()); | |
| Aras.Server.Security.Identity conversionManagerIdentity = Aras.Server.Security.Identity.GetById(conversionIdentityID); | |
| bool conversionManagerPermsWasSet = Aras.Server.Security.Permissions.GrantIdentity(conversionManagerIdentity); | |
| string isInternal = this.getProperty("isInternal", string.Empty); | |
| var taskData = new Dictionary<string, string>() | |
| { | |
| //Here we can add properties to the UserData of the ConversionTask. | |
| //Any string properties can be added here to be passed into the Conversion itself. | |
| {"partBOM", this.getProperty("BOM_Part_Names")}, | |
| }; | |
| string taskId = string.Empty; | |
| var serializedUserData = Newtonsoft.Json.JsonConvert.SerializeObject(taskData); | |
| try | |
| { | |
| //Creating the user_data property to pass the part BOM information to the DLL | |
| taskId = conversionManager.CreateConversionTask(publishingRule, task => | |
| { | |
| task.UserData = serializedUserData; | |
| }); | |
| } | |
| finally | |
| { | |
| //Do anything with the taskId, such as add it to other Items for referencing or other information, here. | |
| if (conversionManagerPermsWasSet) | |
| Aras.Server.Security.Permissions.RevokeIdentity(conversionManagerIdentity); | |
| } | |
| //Omit isInternal if you don't have the property passed in. | |
| //This can be used to allow you to generate Conversion Tasks either on demand or via a daemon user such as a Scheduler process. | |
| if (string.IsNullOrEmpty(isInternal)) | |
| return innovator.newResult(string.Format("Successfully created Conversion Task.")); | |
| return innovator.newResult(taskId); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi Mahesh, Will appreciate if you can help me out on an error I am facing after trying this code out in my server. I am attaching a screenshot of the conversion task and the event handler error.
Regards


Srikumar