Wednesday 26 February 2014

PickMapUpdOnlyIfNull property with Copy pickmap

Today I got to work up on a defect and as I was digging the root cause of the issue for the first time I came to know about this property :-)

Issue
A field exposed in parent applet on editing is not saving properly.The field had a static picklist. I was able to edit the record and I tried changing the value in the picklist but when I save the record the change is not reflected. I selected a new value but on saving the record it gets saved with the same old value

Rootcause
As usual I started with the checking whether the field is a joined field or not. Yeah the field was a joined field but luckily it was an implicit join. Then I moved to the pickmap section and in here everything was good. My field was EHP Med Business Type and the picklist field was value and that was expected. I proceeded to
the PickMapUpdOnlyIfNull property and this what I found there








I goggled to find out what it was and got my answer. This property makes a copy pick map to perform the copy operation only if the values of the fields specified in the pick map UpdOnlyIfNull are null in my case this property had the value EHP Med Business Type which means I could update EHP Med Business Type only when its null so when I tried to update it with another value the issue happened.
Inactivating this property fixed the issue :-)

Invoking a Siebel Business Service through a calculated field

If you are a siebel geek you know how powerful business services are.In my projects my most reliable object is Business service :-).In this post I will explain how you can invoke a business service through a calculated field.

Syntax

For the calculated field in the calculate value field create an expression as below
InvokeServiceMethod("Business Service Name", "Method", "'Input Argument'='Input Value'","Output Argument")

Using the above method the Business service is called for a method with arguments and value returned as output argument is assigned to the calculated field.

It is as simple as that and hope it helps sometimes.

Monday 24 February 2014

Siebel escript to compare two dates

One of the common requirements that I came across multiple projects is to compare two dates and identify which date is greater than the other. I have created a function which can be reused. The function recieves two input dates d1 and d2 and will return 1 if d1 is greater than d2 else return 0

function CompareDates(d1,d2)
{
var date1 = new Date(d1);
var date2 = new Date(d2);
var date1Month = ToInteger(date1.getMonth()+1);
var date1Day = ToInteger(date1.getDate());
var date1Year = ToInteger(date1.getFullYear());
var date2Month = ToInteger(date2.getMonth()+1);
var date2Day = ToInteger(date2.getDate());
var date2Year = ToInteger(date2.getFullYear());
if ((date1Year < date2Year)||((date1Year==date2Year)&&(date1Month < date2Month))||((date1Year==date2Year)&&(date1Month==date2Month)&&(date1Day < date2Day)))
 return(0);
else
 return(1);
}

Refreshing an Applet in Siebel

I encountered an intersting requirement in one of my projects. One a button click parent child assoication should be removed for a record. I wrote script at Applet preinvoke event and in the script I cleared the link field and hence removed the parent child association. However the change did not reflect immediately in the UI for which I needed to refresh the current Applet and the solution that I found out from my guide(GOOGLE) was a vanilla business service FINS Teller UI Navigation and the method invoked is RefreshCurrentApplet.

var svcUI = TheApplication().GetService("FINS Teller UI Navigation");
var psIn = TheApplication().NewPropertySet();
var psOut = TheApplication().NewPropertySet();
svcUI.InvokeMethod("RefreshCurrentApplet",psIn,psOut);

Happy Scripting!!

How to make a field required in Siebel?

If you have any better way of making a field required please share it ,as information shared is information gained. I know possible two ways of implementing it.


1. Making Field required at BC Level

Required field ticked makes it a required field











2. Making field required using scripting
        You can use  server scripting at Applet level or Business Component level to meet the functionality

 if(this.GetFieldValue("Type") == "")
    {
    TheApplication().RaiseErrorText("Attachment type is a required field");
    return(CancelOperation);
    }
        In this case I choose to write the script at business component level and I used the script at prewrite record event. Depending upon your requirement the event chosen can be changed.Basically what done here is you try to get the value of the field using this.GetFieldValue("Type") and if the value returned is null then and error is thrown. Now you may ask why I have not chosen the first method to meet the requirement. If I go to follow the first method then the field will be required at all places where the BC is used since this BC may be used by many applets. Using the second method I can constrain the field to be required in one or multiple views using another if statement.

if(TheApplication().ActiveViewName() == "Members Attachment Detail View" )
    {
    // Added to make Attacment type as required//
    if(this.GetFieldValue("Type") == "")
    {
    TheApplication().RaiseErrorText("Attachment type is a required field");
    return(CancelOperation);
    }
   
    }
In this case the field will be required only in the particular view mentioned.

Hope this helps! Have a great day:-)