February 28, 2016

Dynamically change start-up view for group of users

Requirement: To have a different start-up view for certain group of users in application.

Siebel sets start-up view of all the users using Application property which is a static view and the only way default view can be changed is by end user by updating user preferences. 

Solution: To make the view dynamic and override the user preferences following script can be added to Application_Start event of Application to redirect all the users to a specific view based on their responsibility.  These views can be used to show statuary information or terms and conditions.

Script queries Employee BC for logged in user and search for specific responsibility and executes a go to view if specific responsibility is found. Similar script can be used to change other part of the application. Feel free to share in comments below if you have come across similar behavior in your implementation.

var EmployeeBO = TheApplication().GetBusObject("Employee");
var EmployeeBC = EmployeeBO.GetBusComp("Employee");
var userResp;
with (EmployeeBC)
{
ActivateField("Login Name");
ActivateField("Responsibility");
var UserName = TheApplication().LoginName();
SetSearchSpec("Login Name", TheApplication().LoginName());
ExecuteQuery(ForwardOnly);
if(FirstRecord()){
userResp = GetFieldValue("Responsibility");
}
return (CancelOperation);
}
if( userResp == ""){
{
TheApplication().GotoView("");
}else{
return (ContinueOperation);
}


Hope it helps

1 comment :

  1. Hi, Shall we write above script like this way , because i have not idea why cancel operation is used in above script.

    var EmployeeBO = TheApplication().GetBusObject("Employee");
    var EmployeeBC = EmployeeBO.GetBusComp("Employee");
    var userResp;
    with (EmployeeBC)
    {
    ActivateField("Login Name");
    ActivateField("Responsibility");
    var UserName = TheApplication().LoginName();
    SetSearchSpec("Login Name", UserName);
    ExecuteQuery(ForwardOnly);
    if(FirstRecord()){
    userResp = GetFieldValue("Responsibility");}
    if( userResp == "Developer"){
    {
    TheApplication().GotoView("My XYZ Page");
    }
    else{
    return (ContinueOperation);
    }


    Please correct script , if it is wrong.

    Thanks
    HS

    ReplyDelete