Sunday, Jun. 25, 2017

How to condtionally disable the popup alerts

Written By:

|

September 28, 2012

|

Posted In:

Requirement:

Requirement is to conditionally disable the alert to the user “Do you really want to delete the record, Yes or No” for manually created record (Record created by user using New button), but for automatically / vanilla created records, vanilla functionality of Delete records should be followed.

Solution:

Follow the below steps to implement the solution of this requirement.

1. Go to your BC and create a new field called “Manually Created Record” with field property as below:

Name: Manually Created Record
Type: DTYPE_BOOL
Column: Base it on a column in the table.
Predefault Value: N

2. Go to your applet and write the below script on Applet_PreInvoke event of the Browser script:

function Applet_PreInvokeMethod (name, inputPropSet)
{
if (name == “DeleteRecord”) //Check for Delete Record method being invoked
{
var flg = this.BusComp().GetFieldValue(“Manually Created Record”);
var psid = this.BusComp().GetFieldValue(“Id”);
if (flg == “N”)
{
var inputs = TheApplication().NewPropertySet(); //Declare an input property set
var outputs = TheApplication().NewPropertySet() //Declare an output property set
var bss = TheApplication().GetService(“Delete Record BS”); //A new Custom Business Service created in Step3
inputs.SetProperty(“DeleteId”, psid); //Pass Id of the record in input property set
var resp = bss.InvokeMethod(“CustomDelete”, inputs,outputs); //Invoke the Custom method of the custom Business service
return (“CancelOperation”);
}
}
return (“ContinueOperation”);
}
3. Create a new Custom business service as below:
popup1

‘CustomDelete’ is the method created for this custom business service called “Delete Record BS”

Add the following lines of code to this custom BS event called as Applet_PreInvoke

function Service_PreInvokeMethod (MethodName, Inputs, Outputs)
{
if (MethodName == “CustomDelete”)
{
var boAccount = TheApplication().GetBusObject(“<BO name>”); //Get the BO instance
var bcConAddr = boAccount.GetBusComp(“<BC Name>”); //Get the BC instance
bcConAddr.SetViewMode(AllView);
bcConAddr.ClearToQuery();
bcConAddr.SetSearchSpec(“Id” ,Inputs.GetProperty(“DeleteId”)); //Search the rowid
bcConAddr.ExecuteQuery(ForwardOnly);
var bFound = bcConAddr.FirstRecord();
if (bFound)
{
bcConAddr.DeleteRecord(); //Delete the record
return(CancelOperation);
}
}
return (ContinueOperation);

}

4. In Siebel Tools go to your Application object and query with your application name and create a new record in Application user property as below:

popup2

Ensure that you add this user property for browser script to invoke the server side scripting of the custom Business Service.

5. Compile the objects and generate genB scripts.



Share This Article

About Author

Gurdeep

Hi, I am sharing my experience to alleviate beginners with open UI and HI version of Siebel CRM. I work in Sun Life Financials and can be reached via IT Tool box as well. Thanks.

Comments are closed.

Leave A Reply