Before I start with the post I want to say. I know Scripting is not good for upgrades, performance and I try to avoid it as much as I can. But a recent requirement that I worked upon has got me thinking and I don’t seem to have an answer.
Create a button on a List Applet. On Click of that button the Status of SR should get changed to ‘Close SR’.
As we all know there are several ways to this requirement. If button was not involved then a Simple On Field Update Set n user property would have sufficed. In this case we need to invoke a custom method that should set the field value. That leaves us with two approaches
Create a Named Method n user property. Invoke a workflow and set the status to ‘Close SR’. The workflow and user property will look something like this.
Named Method 10 :
"CloseSR", "INVOKESVC", "Service Request", "Workflow Process Manager", "RunProcess", "'ProcessName'", "Close Service Request", "'RowId'", "[Id]"
In the Service Request BC BusComp_PreInvokeMethod do the following
if(MethodName == “CloseSR”)
I know scripting is bad and scripting on Objects is even worse but we can clearly see that Approach 1 involves calling a business service (Workflow Process Manager) to invoke workflow and Approach 2 is just doing a SetFieldValue. I think the effort in Approach 1 is higher as well as the overhead involved to complete the task. So, what should we do in this case.
I understand the point that it starts like this and over a period of time it becomes a mess but if I start following the Approach 1 for all the similar requirement I believe the situation will get worse. I am not really sure what is the best thing to do here so I am putting this here in the open for everybody to give there opinion and find the best possible answer.
I am listening………
Suggestion by Sudha worked great. I was able to achieve the solution by creating two Named Method n user properties to set the values for two fields.
Thanks Sudha and everyone for discussing and hopefully this will help others to avoid scripting in similar situations.