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.

OkAvarageGoodVery GoodExcellent (2 votes, average: 3.5 out of 5)
Loading ... Loading ...