For those of you who are migrating over from AgilePoint NX v 5.x to AgilePoint NX might notice taht the C# snippet workflow activity is missing. C# shape has been knowingly left out of NX as it was seen as big security concern for lot of people as it can be really dangerous if C# can be injected directly from browser window. Here are some details.
Before I explain a bit more detail on why C# snippet is being deprecated and alternatives for you to use, I would like to make it clear that C# snippets used in existing models would continue working even in NX since the runtime component is still there on the server i.e. any legacy process (V5.x) which has used it will still work.
However we strongly recommend not to write inline snippets this way going forward for new NX apps due to following reasons
- Previously AgilePoint Envision which is a an add-in to Visio use to be installed on only designer machine and no one else would have access to it. Anything you do with C# shape will be compiled on your local machine and security wise it was not that big a deal. However now that we have web based designer which can help you get rid of any client software and having to manage local VSD files, lot more people can have access to designer and if C# shape is kept open you will provide a way for people to push c# scripts from browser to the server which is not a good idea from security point of view.
- C# editor cannot be created in JavaScript based system as it cannot load .Net framework and compile code before you publish. Also intellisence won’t work as .Net or your custom DLL won’t be loaded in JavaScript.
- As now things are done over browser, providing capability to publish C# code over browser would open security hole for malicious script running in your browser which can destabilize your server.
Knowing this C# and VB.Net shapes were deprecated in NX. These are the only shapes which won’t be done due to security reason. Encapsulating code behind REST or WCF service would be a better way so that you can control security better. We also have revamped AgilePoint Developer component released as well which allows ways of creating custom AgileParts but then that will depend if you have reusable code then write AgilePart else wring REST service or WCF will be equally viable since both AgilePart or REST/WCF will be same kind of code.
However the main reason people will use C# snippet is because they wanted some temporary calculation done or loop through schema nodes etc. Our new forms already have way of doing that in form level JavaScript so client don’t really need to do C#. JavaScript lets you cover everything which C# covered and perhaps lot more. That is what we do if we had to inject any calculation or temp variable. So in a way just choice of scripting language has changed to a more client side script. Also form has formula fields which does calculations for you in drag and drop configurable way. For looping through schema nodes there are enhanced shapes which handle it without you having to do it in code.
If you feel you still need some other generic shape to plugin C# and execute it you always have few more options
- External command shape is there which you can use to execute any C# snippet kept on your server. This is more secure as code snippet is not pushed through browser. This is a good option for C# as you can test your code independent of process and then just invoke it securely. Only thing which changes is that instead of embedding the C# in model, you externalize it. Rest everything remains same from coding perspective. This is available as an option for OnPrem systems only.
- PowerShell shape lets you execute PowerShell on server side to invoke C# kind of scripts kept on server. This is available as an option for OnPrem systems only.
- If you wish something more custom built we can do it as part of WebServices/REST/WCF.
If you really need to stick with C# but don’t want to have wrapper REST/WCF service, option 1 and 2 should meet your needs but also keep security in place.
Anyways as I said you won’t have to worry about existing models immediately as C# shape would continue to work for those but going forward we recommend looking at other secured alternatives mentioned above.