Tuesday 29 March 2022

Working with Attachments in Siebel - Part1 Calculating Size

 Hello All, 

Siebel Attachment's are very useful functionality to attach documents, files ,images etc. with parent records.

There are certain consideration with attachment that comes into picture one day or the other.

1. Size Restriction on Attachments

2. Type Restriction on Attachments

3. Size control for Siebel File System

4. FS Cleanup to clear orphan Attachments

lets cover these one by one, 

before starting let us first check the total size of attachments under a particular entity, (Service Request in my case)

Client Side BS to get the Size of attachment

function Service_PreInvokeMethod (MethodName, Inputs, Outputs)

{

try

 {    

  if(MethodName == "DeleteAttachment")

  {

   var vSRBO = TheApplication().GetBusObject("Service Request (eService)");

   var vSRBC = vSRBO.GetBusComp("Service Request (eService)");

   var vSRBCAtt = vSRBO.GetBusComp("Service Request Attachment");

   var fileSize ="0",filebyte="0";

   with(vSRBC)

      {

      ActivateField("Id");

      ClearToQuery();

      SetViewMode(AllView);  

      var varSpec = "[Created] >= '1/1/2020' AND [Created] <= '1/1/2022'";

      SetSearchExpr(varSpec);

  ExecuteQuery(); 

      var vFirstRec = FirstRecord();

  while(vFirstRec)

   {

with(vSRBCAtt)

{

ActivateField("ActivityFileName");

ActivateField("ActivityFileSize");

ClearToQuery();

SetViewMode(AllView);  

ExecuteQuery(); 

var FirstRec = FirstRecord();

  while(FirstRec)

  {    

  var filename = GetFieldValue("ActivityFileName"); 

  filebyte = GetFieldValue("ActivityFileSize");

  fileSize = ToNumber(fileSize)+ToNumber(filebyte);

  FirstRec = NextRecord();

  }  

}     

   vFirstRec = NextRecord();

 

   }  

TheApplication().RaiseErrorText("TotalSize: "+fileSize);

   }  

   return(CancelOperation);

  }

 }//End Try

 catch(e)

 {

 // return(CancelOperation);

  if (typeof e.errText == "undefined")

  TheApplication().RaiseErrorText(e.toString());

  else

  TheApplication().RaiseErrorText(e.errText + "\n" + e.toString());

 }

 finally

 {

   vSRBO = null;

   vSRBC = null;

 }

}


the output will be in bytes , we can convert to MegaBytes by dividing by 1024, or GigaBytes by dividing 1024*1024

As Highlighted by Alex Sir , it will be divide by 1,000,000 not 1024 to convert to Mega Bytes

here, 10306580 if Divided by 1024*1024 gives 9.82 GB








We will continue with Putting restriction on file attachments in next post.

Sunday 27 March 2022

Application Level Functions in Siebel - LookupDesc

 Hello All,

There have been certain requirement that makes us write repetitive code, like sending email or SMS where we need to write either a function or script each time we need to call the code. Can there be some better way of handling this type of repetitive code? 

Application Level functions are the solution to these type of requirement. Consider one more case we use LookupValue functions to fetch LOV value that gives us either Name or Display Value. In case when length is more then 30 we need to call custom code.

Here we can make a Application level function say LookupDesc that returns Description and can be call by TheApplication() method.

See sample code for the same

//Your public declarations go here...
 function LookUpDesc(Type,Value)
{
 try
{
var sDesc = "";
var boLOV = TheApplication().GetBusObject("List Of Values");
var bcLOV = boLOV.GetBusComp("List Of Values");
with (bcLOV)
{
ClearToQuery();
SetViewMode(AllView);
ActivateField("Description");
SetSearchSpec("Type", Type);
SetSearchSpec("Value", Value);
ExecuteQuery(ForwardOnly);
if (FirstRecord())
 {
sDesc = GetFieldValue("Description");
 }
}
//with
return(sDesc);
}
catch(e)
 {
 throw(e);
}
 finally
{
bcLOV = null;
boLOV = null;
} }

Add this function in Application:















You can use this with below Syntax:








try and explore the code reusability :-)

Siebel GoTo View - Handling Realtime cases

 Hello All,  We all must have used GoTo view functionality of siebel to navigate to a particular view from current view. What if the require...