A reader of Siebel Unleashed asked for a solution of a requriement. It was an interesting requirement and one which anybody could come across.So, I thought of sharing it with everybody
Requirement:
On Service Request Screen we have a View where SR is Parent and Activity is Child of SR. If All the Child activities are marked with Status as done for a particular SR then a flag called SRAct Flag should be marked as true otherwise it should be marked as false.
I hope I am clear with the requirement.
Solution:
As usual there are two ways to do this requirement.
Scripting Solution:
On the write record of Action BC write the following Script
var searchExp;
searchExp = “[Activity SR Id] = ‘” + this.GetFieldValue(“Activity SR Id”) + “‘ AND [Status] <> ‘Done’”;
var boSR = TheApplication().GetBusObject(“Service Request”);
var bcSR = boSR.GetBusComp(“Service Request”);
var actbc = boSR.GetBusComp(“Action”);
var SRId = this.GetFieldValue(“Activity SR Id”); // Field storing SR Id
bcSR.ClearToQuery();
bcSR.SetViewMode(3);
bcSR.ActivateField(“SRAct Flag”);
bcSR.SetSearchSpec(“Id”,SRId);
bcSR.ExecuteQuery();
if(bcSR.FirstRecord())
{
actbc.ClearToQuery();
actbc.SetViewMode(3);
actbc.SetSearchExpr(searchExp);
actbc.ExecuteQuery();
if(!actbc.FirstRecord())
{
bcSA.SetFieldValue(“SRAct Flag”,”Y”);
bcSR.WriteRecord();
}
}
Explaination:
This code is executing a query on Action BC checking if there is a record whose status is not ‘Done’ If Not then set the SRAct Flag as Y on Service Request
I know I am going to raise eyebrows of many with this script but I here are some things that I would like to clear straight away.
- This code is going to fire every time you save an activity record. You could add a condition over this code that it should only execute if Status field is set on Action BC to reduce the number of times this code is executed.
- Some of you might think that getting an inactive instance of SR BC is not required and we can we straightaway do this.ParentBusComp().SetFieldValue but I must remind you that Activity also has an independent screen and it doesn’t have any parent on that screen, in that case your code is going to give error. So, this is necessary if you want your code to work from SR as well as Activities Screen
- Last but not the least I have modified a working code to get this code. So, if you try to use it AS IS then you might face some error. Please modify accordingly.
In next post I will discuss Script less solution for this same requirement. Till then have good day.



(3 votes, average: 3.33 out of 5)





totally insane method of doing this
That’s new one
May I dare to ask what will be a sane method to do it???
I have achieved this through configuration.
Totally agree with TEST. This could be easily done just only using configuration. Scripting is evil
and should be used only as last resort.
When I was writting this post I knew I was opening a pandora’s box. The purpose was not to encourage scripting to do everything.
It is quite easy to say this is wrong but what is difficult is tell right thing.
I agree with you that this is not the optimal solution of this problem but would any of you guys would share the configuration solution with us. I am also exploring that option I will post it once done… but till then if any of you out there could share it with us it would be great
Here is config solution:
To achive mentioned functionality we need 3 things – multi-value link (MVL), multi-value field (MVF) and calculated field. Fortunately, there are already MVL “Action” and MVF “Activity Status” in Service Request BC (at least in Siebel 8.0). That’s exactly what is needed and the only thing we should to add is our “SRAct Flag” field, which will be calculated and will have following value: IIF(EXISTS([Activity Status] “Done”),”N”,”Y”)
Between [Activity Status] and “Done” should be “not equal to” operator. Due to some reason it disappeared from comment
I think MVF is not needed. We can added a search spec on the MVL such as [Activity Status] “Done”. Then on the SR BC we can create a calculated Field as “SRAct Flag”. Its calculated Value: IIF(Count(“MVL”)>0, “N”, “Y”).
But this solution will impact the performance because of using the MVL.
good one fedor,you7246mk for suggesting the config based solution…both of these solution require server outage…BUT I worked on similar requirement(defect) which come post live…& user insisted to provide the solution…will let you know how to do it…
Test, I think you need a short-term solution. You can write a BS on the server to implement the logic. (Navigate to Administration->Business Service) So the BS don’t need to be compiled. Then you can set a Runtime Event on the server to run the BS.
fedor,
This is a nice solution but my requirement SRAct is a base field flag not to have a calculated field that is updated.
The reason is that I would like to do setup a policy based on this flag can you modify your solution to reflect this.
Hi Neel,
This is one of the nice articles. Actually, i am new to the scripting. I could not understand the meaning of “actbc.SetSearchExpr(str);” in the above script. if you donot mind could you explain the meaning of that.
Sorry it’s my mistake. It should be
actbc.SetSearchExpr(searchExp); not actbc.SetSearchExpr(str);
I hope it is clear now. I am just creating a search experssion and then executing it using SetSearchExpr
Hi Neel,
I hav esome defferent approach without code. i will explain in brief, let me know if you are not clear.
Steps:
1. Create the Run Time Events with
Event:WriteRecord
Conditional Expr- GetFieldValue(“Status”)=”Done”– I gave an ex. you pick it from hte Pick List correct field names.
2. Create WorkFlow
Steps:
use this PRM ANI Utility Service BS and method QueryBusComp
Inputs:BC Name
SeacrchCpec:{Status]’Done’
If records found means there are some activities with other status
else Update the SRAct Flag field using the Update Method of adapter BS in hte next Step.
3. Update SRAct Flag Field
BS:EAI Siebel Adapter
Method:Update.
4 End.
Let me know if u need more detail or it’s ok.
Hi Siddu,
Your approach is quite clear but there are couple of things that I would say here.
First the conditional expression should be different as Activities are available under different screens so there should be a check of view.
and instead of EAI Siebel Adapter I would use normal siebel update operation because EAI Siebel Adapter would require me to create an IO which is not required in this case.
I just wrote a post today explaining scriptless solution here is the url of the post
http://siebelunleashed.com/closing-service-request-%e2%80%93-scriptless-siebel/
I need Config solution for above functionality. how can i count all records in child and update flag on parent?
We had this similar requirement and we also achieved thru MVL and Calculated field.
We created an MVL (ParentMVL) on Parent BC which was mapped to the Calculated Field (Field1) as the Destination field of the Child BC.
This Field1 is a calculated field that counts the number of Flag values that are FALSE. If there is any record on this count then they are not setting the Header value.
We had this similar requirement and we also achieved thru MVL and Calculated field.
We created an MVL (ParentMVL) on Parent BC which was mapped to the Calculated Field (Field1) as the Destination field of the Child BC.
This Field1 is a calculated field that counts the number of Flag values that are FALSE. If there is any record on this count then they are not setting the Header value.
ex. ChildBC: Field1 (calculated on ABC)
IIF ((([ABC] = ‘N’ OR [ABC] is null ) AND ([Root Id] = [Row Id])),1,0)
***where Root Id is the Parent Line Item (for a hierarchical structure).
Now in Parent BC:
Create a Field and associate with ParentMVL (say XYZ)
Now use that Parent Calculated field(say PQR)
PQR will be:
IIf (IfNull (Sum ([XYZ]), 0) = 0, ‘Y’, ‘N’)
SUM(MVF) would be good option for this, because COUNT(MVL) need refresh when child record is updated means at the time when we complete last activity the flag of SR will be FALSE, but once we do Refresh record in SR BC flag will be true.
but SUM(MVF) refresh immidiatly while we complete last activity.
Point to Check: MVF field must have type DTYPE_INTEGER or DTYPE_NUMBER
How to do reverse of this. Updating Child record based on Parent record?