Script From Infosys
Script From Infosys
}
2
/*bcQuoteItem.ActivateField("Discount Percent");
var test = bcQuoteItem.GetFieldValue("Id");
bcQuoteItem.SetFieldValue("Discount Percent", sTWPct);
bcQuoteItem.WriteRecord();*/
var sBS = TheApplication().GetService("SIS OM PMT Service");
var sIP = TheApplication().NewPropertySet();
var sOP = TheApplication().NewPropertySet();
sIP.SetProperty("Business Object Name","Quote");
sIP.SetProperty("Business Component Name","Quote Item");
sBS.InvokeMethod("Refresh Business Component",sIP,sOP);
return (CancelOperation);
}
return (ContinueOperation);
}//try
3
oBCQuoteTemplate = oBO.GetBusComp("CMI Quote Template");
}
var sQuoteTemplateId = oBCQuoteTemplate.GetFieldValue ("Id");
var sPickQuoteId = oBCPickQuote.GetFieldValue("Id");
//added by jacky
oBCPickQuote.ActivateField("Requested Ship Date");
var sDueDate = oBCPickQuote.GetFieldValue("Requested Ship Date");
oBCPickQuote.ActivateField("Source Inventory Location Id");
var sLocId = oBCPickQuote.GetFieldValue("Source Inventory Location Id");
oBCPickQuote.ActivateField("Currency Code");
var sCurcyCd = oBCPickQuote.GetFieldValue("Currency Code");
var sQuoteAccCd = oBCPickQuote.GetFieldValue("CMI Asset Access Code");
oBCPickQuote.ActivateField("Ship To Account Id");
oBCPickQuote.ActivateField("Ship To Address Id");
oBCPickQuote.ActivateField("CMI Ship To Profile Id");
oBCPickQuote.ActivateField("Carrier Priority");
oBCPickQuote.ActivateField("Carrier Code");
var sShipAcId = oBCPickQuote.GetFieldValue("Ship To Account Id");
var sShipAddrId = oBCPickQuote.GetFieldValue("Ship To Address Id");
var sShipProfId = oBCPickQuote.GetFieldValue("CMI Ship To Profile Id");
var sCarCode = oBCPickQuote.GetFieldValue("Carrier Code");
var sCarPri = oBCPickQuote.GetFieldValue("Carrier Priority");
//Code added by IY795 for revision from quote if status is not In Progress
var sStatus = oBCPickQuote.GetFieldValue("Status");
if(sStatus != TheApplication().InvokeMethod("LookupValue", "QUOTE_STATUS", "In Progress"))
{
oBCPickQuote.InvokeMethod("ReviseCopyQuote");
var sNewQuoteId = oBCPickQuote.GetFieldValue("Id");
sPickQuoteId = sNewQuoteId;
}
var QuoteIdReq = sPickQuoteId;// defect 353
var oBCPickQuoteItem = oBO.GetBusComp("Quote Item");
with (oBCPickQuoteItem)
{
SetViewMode(AllView);
ClearToQuery();
SetSearchSpec("Quote Id",sPickQuoteId);
SetSortSpec("Line Number(DESCENDING)");
ExecuteQuery(ForwardOnly);
var isRecordPickQuoteItem = FirstRecord();
}
var iMaxLineNumber = 0;
var iPickQuoteItemCount = 0;
if (isRecordPickQuoteItem)
{
iMaxLineNumber = ToNumber(oBCPickQuoteItem.GetFieldValue("Line Number"));
iPickQuoteItemCount = oBCPickQuoteItem.CountRecords();
if (iMaxLineNumber == 0 )
{
iMaxLineNumber = iPickQuoteItemCount;
}
4
}
var oBOQ = TheApplication().GetBusObject("CMI Quote");
var oBCQuote = oBOQ.GetBusComp("CMI Quote Simple");
var oBCQuoteItem = oBOQ.GetBusComp("CMI Quote Item Lite");
var iProcessed = 0;
with (oBCQuote)
{
SetViewMode(AllView);
ClearToQuery();
SetSearchSpec("Id",sQuoteTemplateId);
ExecuteQuery(ForwardOnly);
var icount = oBCQuoteItem.CountRecords();
var isRecord = FirstRecord();
if (isRecord)
{
with (oBCQuoteItem)
{
SetViewMode(AllView);
ActivateField("Product Id");// defect 353
ActivateField("Quantity Requested");// defect 353
ActivateField("CMI SRT Quantity");// defect 353
ActivateField("Product Type");// defect 353
ActivateField("CMI Serialized Flag");// defect 353
ActivateField("CMI SRT Id");// defect 353
ActivateField("Line Number");
ActivateField("Requested Delivery Date");
ActivateField("Source Inventory Location Id");
ActivateField("Quote Id");
ActivateField("CMI Work Sequence");
ActivateField("Currency Code");
ActivateField("Ship To Account Id");
ActivateField("Ship To Address Id");
ActivateField("CMI Ship To Profile Id");
ActivateField("Revised Line Item Id");
ActivateField("Carrier Code");
ActivateField("Shipping Method");
SetSearchSpec("Quote Id",sQuoteTemplateId);
SetSortSpec("Line Number(DESCENDING)");
ClearToQuery();
ExecuteQuery();
var icount1 = oBCQuoteItem.CountRecords();
var isRecord1 = FirstRecord();
while ( iProcessed < icount1 && isRecord1)
{
var Prodid = GetFieldValue("Product Id");// defect 353
var Quantityhv = GetFieldValue("Quantity Requested");// defect 353
var SFlag = GetFieldValue("CMI Serialized Flag");// defect 353
var ProdType = GetFieldValue("Product Type");// defect 353
var SRTQuantity = GetFieldValue("CMI SRT Quantity");// defect 353
var SRTId = GetFieldValue("CMI SRT Id");// defect 353
5
if((SFlag != "Y") && ((ProdType == sProdVal1)||(ProdType == sProdVal2)||(ProdType ==
sProdVal3)||(ProdType == sProdVal4)))
{
UpdateQuantity(QuoteIdReq,Prodid,Quantityhv,ProdType,SRTQuantity,SRTId);
}
if((SFlag == "Y")||(TheApplication().GetProfileAttr("ChangeDone")!="Y"))
{
var iTQIRowId = GetFieldValue("Id");
var iLineNumber = GetFieldValue("Line Number");
NewRecord(NewAfterCopy);
SetFieldValue("Quote Id",sPickQuoteId);
SetFieldValue("Source Inventory Location Id",sLocId);
SetFieldValue("Requested Delivery Date",sDueDate);
var iLineNumberNew = GetFieldValue("Line Number");
iMaxLineNumber = ToNumber(iMaxLineNumber) + 1;
// SetFieldValue("Line Number",GetFieldValue("Line Number")+icount1);
SetFieldValue("Line Number", iMaxLineNumber);
SetFieldValue("CMI Work Sequence", iMaxLineNumber);
SetFieldValue("Currency Code", sCurcyCd);
SetFieldValue("Ship To Account Id", sShipAcId);
SetFieldValue("Ship To Address Id", sShipAddrId);
SetFieldValue("CMI Ship To Profile Id", sShipProfId);
var sQuoteItemId = GetFieldValue("Id");
SetFieldValue("Revised Line Item Id", sQuoteItemId);
SetFieldValue("Carrier Code", sCarCode);
SetFieldValue("Shipping Method", sCarPri);
WriteRecord();
}
7
var sProdVal3 = TheApplication().InvokeMethod("LookupValue",
"PRODUCT_TYPE", "Labor");// defect 353
var sProdVal4 = TheApplication().InvokeMethod("LookupValue",
"PRODUCT_TYPE", "Misc");// defect 353
if (TheApplication().ActiveViewName() == "CMI SR Failure Code Quote Template View")
{
oBCQuoteTemplate = oBO.GetBusComp("Quote Template");
}
else
{
oBCQuoteTemplate = oBO.GetBusComp("CMI Quote Template");
}
var sQuoteTemplateId = oBCQuoteTemplate.GetFieldValue ("Id");
var sPickQuoteId = oBCPickQuote.GetFieldValue("Id");
//added by jacky
oBCPickQuote.ActivateField("Requested Ship Date");
var sDueDate = oBCPickQuote.GetFieldValue("Requested Ship Date");
oBCPickQuote.ActivateField("Source Inventory Location Id");
var sLocId = oBCPickQuote.GetFieldValue("Source Inventory Location Id");
oBCPickQuote.ActivateField("Currency Code");
var sCurcyCd = oBCPickQuote.GetFieldValue("Currency Code");
var sQuoteAccCd = oBCPickQuote.GetFieldValue("CMI Asset Access Code");
oBCPickQuote.ActivateField("Ship To Account Id");
oBCPickQuote.ActivateField("Ship To Address Id");
oBCPickQuote.ActivateField("CMI Ship To Profile Id");
oBCPickQuote.ActivateField("Carrier Priority");
oBCPickQuote.ActivateField("Carrier Code");
var sShipAcId = oBCPickQuote.GetFieldValue("Ship To Account Id");
var sShipAddrId = oBCPickQuote.GetFieldValue("Ship To Address Id");
var sShipProfId = oBCPickQuote.GetFieldValue("CMI Ship To Profile Id");
var sCarCode = oBCPickQuote.GetFieldValue("Carrier Code");
var sCarPri = oBCPickQuote.GetFieldValue("Carrier Priority");
//Code added by IY795 for revision from quote if status is not In Progress
var sStatus = oBCPickQuote.GetFieldValue("Status");
if(sStatus != TheApplication().InvokeMethod("LookupValue",
"QUOTE_STATUS", "In Progress"))
{
oBCPickQuote.InvokeMethod("ReviseCopyQuote");
var sNewQuoteId = oBCPickQuote.GetFieldValue("Id");
sPickQuoteId = sNewQuoteId;
}
var QuoteIdReq = sPickQuoteId;// defect 353
var oBCPickQuoteItem = oBO.GetBusComp("Quote Item");
with (oBCPickQuoteItem)
{
SetViewMode(AllView);
ClearToQuery();
SetSearchSpec("Quote Id",sPickQuoteId);
SetSortSpec("Line Number(DESCENDING)");
ExecuteQuery(ForwardOnly);
var isRecordPickQuoteItem = FirstRecord();
8
}
var iMaxLineNumber = 0;
var iPickQuoteItemCount = 0;
if (isRecordPickQuoteItem)
{
iMaxLineNumber =
ToNumber(oBCPickQuoteItem.GetFieldValue("Line Number"));
iPickQuoteItemCount = oBCPickQuoteItem.CountRecords();
if (iMaxLineNumber == 0 )
{
iMaxLineNumber = iPickQuoteItemCount;
}
}
var oBOQ = TheApplication().GetBusObject("CMI Quote");
var oBCQuote = oBOQ.GetBusComp("CMI Quote Simple");
var oBCQuoteItem = oBOQ.GetBusComp("CMI Quote Item Lite");
var iProcessed = 0;
with (oBCQuote)
{
SetViewMode(AllView);
ClearToQuery();
SetSearchSpec("Id",sQuoteTemplateId);
ExecuteQuery(ForwardOnly);
var icount = oBCQuoteItem.CountRecords();
var isRecord = FirstRecord();
if (isRecord)
{
with (oBCQuoteItem)
{
SetViewMode(AllView);
ActivateField("Product Id");//
ActivateField("Quantity Requested");//
ActivateField("CMI SRT Quantity");//
ActivateField("Product Type");//
ActivateField("CMI Serialized Flag");//
ActivateField("CMI SRT Id");//
ActivateField("Line Number");
ActivateField("Requested Delivery Date");
ActivateField("Source Inventory Location Id");
ActivateField("Quote Id");
ActivateField("CMI Work Sequence");
ActivateField("Currency Code");
ActivateField("Ship To Account Id");
ActivateField("Ship To Address Id");
ActivateField("CMI Ship To Profile Id");
ActivateField("Revised Line Item Id");
ActivateField("Carrier Code");
ActivateField("Shipping Method");
SetSearchSpec("Quote Id",sQuoteTemplateId);
SetSortSpec("Line Number(DESCENDING)");
ClearToQuery();
9
ExecuteQuery();
var icount1 = oBCQuoteItem.CountRecords();
var isRecord1 = FirstRecord();
while ( iProcessed < icount1 && isRecord1)
{
var Prodid = GetFieldValue("Product Id");// defect 353
var Quantityhv = GetFieldValue("Quantity Requested");// defect 353
var SFlag = GetFieldValue("CMI Serialized Flag");// defect 353
var ProdType = GetFieldValue("Product Type");// defect 353
var SRTQuantity = GetFieldValue("CMI SRT Quantity");// defect 353
var SRTId = GetFieldValue("CMI SRT Id");// defect 353
if((SFlag != "Y") && ((ProdType == sProdVal1)||(ProdType == sProdVal2)||(ProdType ==
sProdVal3)||(ProdType == sProdVal4)))
{
UpdateQuantity(QuoteIdReq,Prodid,Quantityhv,ProdType,SRTQuantity,SRTId);
}
if((SFlag == "Y")||(TheApplication().GetProfileAttr("ChangeDone")!="Y"))
{
var iTQIRowId = GetFieldValue("Id");
var iLineNumber = GetFieldValue("Line Number");
NewRecord(NewAfterCopy);
SetFieldValue("Quote Id",sPickQuoteId);
setFieldValue("Source Inventory Location Id",sLocId);
//added by jacky
SetFieldValue("Requested Delivery Date",sDueDate);
var iLineNumberNew = GetFieldValue("Line Number");
iMaxLineNumber = ToNumber(iMaxLineNumber) + 1;
// etFieldValue("Line Number",GetFieldValue("Line Number")+icount1);
SetFieldValue("Line Number", iMaxLineNumber);
SetFieldValue("CMI Work Sequence", iMaxLineNumber);
SetFieldValue("Currency Code", sCurcyCd);
SetFieldValue("Ship To Account Id", sShipAcId);
SetFieldValue("Ship To Address Id", sShipAddrId);
SetFieldValue("CMI Ship To Profile Id", sShipProfId);
var sQuoteItemId = GetFieldValue("Id");
SetFieldValue("Revised Line Item Id", sQuoteItemId);
SetFieldValue("Carrier Code", sCarCode);
SetFieldValue("Shipping Method", sCarPri);
WriteRecord();
}
TheApplication().SetProfileAttr("ChangeDone
var iNewCurrRowId = GetFieldValue("Id");
isRecord1 = NextRecord();
iProcessed = ToNumber(iProcessed) + 1;
var iNextRecordId = GetFieldValue("Id");
while ( iProcessed < icount1 && iNextRecordId == iTQIRowId )
{
isRecord1 = NextRecord();
iNextRecordId = GetFieldValue("Id");
}
// }
10
}
}
}
}
sValid = CheckSRTValidity(oBCQuote, oBCQuoteItem, sPickQuoteId, sQuoteAccCd);
// Go to 'CreateFailureCode' Function
if ( TheApplication().ActiveViewName() == "CMI Service Request Quote Template List View")
{
var sFailCdId = oBCQuoteTemplate.GetFieldValue("CMI Failure Id");
var sSRID = oBCPickQuote.GetFieldValue("Service Request Id");
CreateFailureCode(sFailCdId, sSRID);
}
}
var iMaxLineNumber = 0;
var iPickQuoteItemCount = 0;
if (isRecordPickQuoteItem)
{
iMaxLineNumber = ToNumber(oBCPickQuoteItem.GetFieldValue("Line Number"));
iPickQuoteItemCount = oBCPickQuoteItem.CountRecords();
if (iMaxLineNumber == 0 )
{
iMaxLineNumber = iPickQuoteItemCount;
}
}
var oBOQ = TheApplication().GetBusObject("CMI Quote");
var oBCQuote = oBOQ.GetBusComp("CMI Quote Simple");
var oBCQuoteItem = oBOQ.GetBusComp("CMI Quote Item Lite");
var iProcessed = 0;
with (oBCQuote)
{
SetViewMode(AllView);
ClearToQuery();
SetSearchSpec("Id",sQuoteTemplateId);
ExecuteQuery(ForwardOnly);
var icount = oBCQuoteItem.CountRecords();
var isRecord = FirstRecord();
if (isRecord)
{
with (oBCQuoteItem)
{
SetViewMode(AllView);
ActivateField("Product Id");// defect 353
ActivateField("Quantity Requested");// defect 353
ActivateField("CMI SRT Quantity");// defect 353
ActivateField("Product Type");// defect 353
ActivateField("CMI Serialized Flag");// defect 353
ActivateField("CMI SRT Id");// defect 353
ActivateField("Line Number");
ActivateField("Requested Delivery Date");
ActivateField("Source Inventory Location Id");
13
ActivateField("Quote Id");
ActivateField("CMI Work Sequence");
ActivateField("Currency Code");
ActivateField("Ship To Account Id");
ActivateField("Ship To Address Id");
ActivateField("CMI Ship To Profile Id");
ActivateField("Revised Line Item Id");
ActivateField("Carrier Code");
ActivateField("Shipping Method");
SetSearchSpec("Quote Id",sQuoteTemplateId);
SetSortSpec("Line Number(DESCENDING)");
ClearToQuery();
ExecuteQuery();
var icount1 = oBCQuoteItem.CountRecords();
var isRecord1 = FirstRecord();
while ( iProcessed < icount1 && isRecord1)
{
var Prodid = GetFieldValue("Product Id");// defect 353
var Quantityhv = GetFieldValue("Quantity Requested");// defect 353
var SFlag = GetFieldValue("CMI Serialized Flag");// defect 353
var ProdType = GetFieldValue("Product Type");// defect 353
var SRTQuantity = GetFieldValue("CMI SRT Quantity");// defect 353
var SRTId = GetFieldValue("CMI SRT Id");// defect 353
// defect 353 to call function "UpdateQuantity"
if((SFlag != "Y") && ((ProdType == sProdVal1)||(ProdType == sProdVal2)||(ProdType == sProdVal3)||
(ProdType == sProdVal4)))
{
UpdateQuantity(QuoteIdReq,Prodid,Quantityhv,ProdType,SRTQuantity,SRTId);
}
if((SFlag == "Y")||(TheApplication().GetProfileAttr("ChangeDone")!="Y"))
{
var iTQIRowId = GetFieldValue("Id");
var iLineNumber = GetFieldValue("Line Number");
NewRecord(NewAfterCopy);
SetFieldValue("Quote Id",sPickQuoteId);
SetFieldValue("Source Inventory Location Id",sLocId);
SetFieldValue("Requested Delivery Date",sDueDate);
var iLineNumberNew = GetFieldValue("Line Number");
iMaxLineNumber = ToNumber(iMaxLineNumber) + 1;
/SetFieldValue("Line Number",GetFieldValue("Line Number")+icount1);
SetFieldValue("Line Number", iMaxLineNumber);
SetFieldValue("CMI Work Sequence", iMaxLineNumber);
SetFieldValue("Currency Code", sCurcyCd);
SetFieldValue("Ship To Account Id", sShipAcId);
SetFieldValue("Ship To Address Id", sShipAddrId);
SetFieldValue("CMI Ship To Profile Id", sShipProfId);
var sQuoteItemId = GetFieldValue("Id");
SetFieldValue("Revised Line Item Id", sQuoteItemId);
SetFieldValue("Carrier Code", sCarCode);
SetFieldValue("Shipping Method", sCarPri);
WriteRecord();
14
}
}//end of try
15
}
function CheckSRTValidity(oBCQuote, BCQuoteItem, sNewQuoteId, sQuoteAccCd)
{
try
{
var isItemRec; var sSRTId; var sAccCd; var sSRTBC;
var sStepBC; var sSRTValidFlg = "N"; var sSRTStepValidFlg = "N";
var sSRTCount = 0; var sSRTStpCount = 0; var sValid = "Y";
with(oBCQuote)
{
SetViewMode(AllView);
ClearToQuery();
SetSearchSpec("Id", sNewQuoteId);
ExecuteQuery(ForwardOnly);
if(FirstRecord())
{
with(BCQuoteItem)
{
SetViewMode(AllView);
ActivateField("CMI SRT Id");
ActivateField("CMI SRT Step Id");
ActivateField("CMI SRT Access Code");
ActivateField("Quote Id");
ActivateField("CMI SRT Description");
ActivateField("CMI SRT Step Num");
ClearToQuery();
SetSearchSpec("Quote Id", sNewQuoteId);
SetSearchSpec("Product Type",
TheApplication().InvokeMethod("LookupValue", "PRODUCT_TYPE", "Labor"));
ExecuteQuery();
isItemRec = FirstRecord();
while(isItemRec)
{
sSRTId = GetFieldValue("CMI SRT Id");
sStepId = GetFieldValue("CMI SRT Step Id");
sAccCd = GetFieldValue("CMI SRT Access Code");
//if(sAccCd == "" || sAccCd == null)
//{
if(sSRTId != null || sSRTId != "")
{
if(sAccCd != "")
{
SetFieldValue("CMI SRT Access Code", sAccCd);
WriteRecord();
}
else
{
etFieldValue("CMI SRT Access Code", sQuoteAccCd);
WriteRecord();
}
}
16
if(sSRTId != null && sSRTId != "")
{
sSRTBC = BCQuoteItem.GetPicklistBusComp("CMI SRT Description");
with(sSRTBC)
{
SetViewMode(AllView);
ClearToQuery();
SetSearchSpec("Id", sSRTId);
ExecuteQuery();
if(FirstRecord())
{
Pick();
}
else
{
sSRTValidFlg = "Y";
if(sSRTValidFlg == "Y")
{
sSRTCount = sSRTCount + 1;
sSRTValidFlg = "N";
}
}
}
}//end of if(SRTId)
//}//end of if(AccCd)
isItemRec = NextRecord()
}//end of isItemRec
}//end of BCQuoteItem
}//end of if(FirstRecord)
}//End of oBCQuote
if(sSRTCount > 0 || sSRTStpCount > 0)
{
sValid = "N";
}
}//end of try
return(sValid);
}
function RemoveWarranty()
{
try
{
var oBO = TheApplication().ActiveBusObject();// SR in this case
var oBCQuote = oBO.GetBusComp("Quote");
var QuoteId = oBCQuote.GetFieldValue("Id");
var SRId = oBCQuote .GetFieldValue("Service Request Id");
var OBCQuoteItem = oBO.GetBusComp("Quote Item");
var oBCSRWarranty = oBO.GetBusComp("CMI Service Request Warranty");
var oBCQIW = oBO.GetBusComp("CMI Quote Item Warranty");
with(OBCQuoteItem)
{
ActivateField("CMI SR Id");
ActivateField("Quote Id")
SetViewMode(AllView);
ClearToQuery();
SetSearchSpec("CMI SR Id", SRId);
SetSearchSpec("Quote Id", QuoteId);
ExecuteQuery();
var IsQuoteItemRec = FirstRecord();
while(IsQuoteItemRec)
{
20
var QuoteItemID = GetFieldValue("Id");
with(oBCQIW)
{
SetViewMode(AllView);
ClearToQuery();
SetSearchSpec("Parent Id", QuoteItemID);
ExecuteQuery();
var IsWarrantyRec = FirstRecord();
while(IsWarrantyRec)
{
DeleteRecord();
IsWarrantyRec = FirstRecord();
}
}
IsQuoteItemRec = NextRecord();
}
}
}//end of try
}
function UpdateQuantity(QuoteIdReq,Prodid,Quantityhv,ProdType,SRTQuantity,SRTId)
{
try
{
var oBO = TheApplication().ActiveBusObject();
var oBC = oBO.GetBusComp("Quote Item");
var Qty;
var NQty;
with(oBC)
{
SetViewMode(AllView);
ActivateField("Product Type");
ActivateField("Quantity Requested");
ActivateField("CMI SRT Quantity");
ActivateField("Quantity Requested Cal");
ActivateField("CMI SRT Hours");
ActivateField("CMI SRT Id");
ClearToQuery();
SetSearchSpec("Quote Id",QuoteIdReq);
ExecuteQuery()
// var R1 = CountRecords();
var isRec = FirstRecord();
while(isRec)
{
var Prodid1 = GetFieldValue("Product Id");
21
var ProdType1 = GetFieldValue("Product Type");
if(Prodid1 == Prodid)
{
if((ProdType1 == sProdVal1)||(ProdType1 == sProdVal2)||(ProdType1 == sProdVal4))
{
Qty = GetFieldValue("Quantity Requested");
NQty = ToNumber(Quantityhv) + ToNumber(Qty);
SetFieldValue("Quantity Requested",NQty);
WriteRecord();
TheApplication().SetProfileAttr("ChangeDone","Y");
}
if(ProdType1 == sProdVal3)
{
//var QtyReq1 = GetFieldValue("Quantity Requested");
var SRTId1 = GetFieldValue("CMI SRT Id");
Qty = GetFieldValue("CMI SRT Quantity");
var SRTHr = GetFieldValue("CMI SRT Hours");
if((SRTId1 != "NULL") && (SRTId1 != ""))
{
if(SRTId1 == SRTId)
{
NQty = ToNumber(SRTQuantity) + ToNumber(Qty);
SetFieldValue("CMI SRT Quantity",NQty);
//var QtyReq1 = GetFieldValue("Quantity Requested Cal");
var QtyReq1 = NQty * ToNumber(SRTHr)
SetFieldValue("Quantity Requested", QtyReq1);
WriteRecord();
TheApplication().SetProfileAttr("ChangeDone","Y");
}
}
}
}
isRec = NextRecord();
}
}
}//end of try
}
CMI QUOTE TO ORDER
function Service_PreInvokeMethod (MethodName, Inputs, Outputs)
{
try
{
if (MethodName == "QuoteToOrder")
{
var oBO = TheApplication().ActiveBusObject();
var oBCQuote = oBO.GetBusComp("Quote");
var sQuoteId = TheApplication().GetProfileAttr("Quote Id");
//perf check
var s1; var e1; var s2;
var e2; var s3; var e3;
22
//perf check
with (oBCQuote)
{
InvokeMethod("SetAdminMode","TRUE");
//SetViewMode(AllView);//Inactivated Script it doesn't invoke on certain logins-09 Feb 2011-Di
//Commented the Quote Querying as it's not required and for performance tuning,<JQ486>
/*ActivateField("Status");
ActivateField("Service Request Id");
ClearToQuery();
SetSearchSpec("Id",sQuoteId);
ExecuteQuery(ForwardOnly);*/
var sStatus = GetFieldValue("Status");
var sStaSet = TheApplication().InvokeMethod("LookupValue",
"QUOTE_STATUS", "Accepted")
sSRNum = GetFieldValue("Service Request Id");
sQuoteNum = GetFieldValue("Quote Number");//added new field as per defect 657
if (sStatus == TheApplication().InvokeMethod("LookupValue",
"QUOTE_STATUS", "Ready to Schedule"))
{
s1 = Clib.asctime(Clib.gmtime(Clib.time())); //perf check
strmsg = "Quote Validation Start Time: " + s1 + " End Time: " + e1 + "\n";//perf check
23
strmsg = strmsg + "\n" + "Signal Invoke Start Time: " + s2 + " End Time: " + e2 + "\n";//perf check
strmsg = strmsg + "\n" + "Quote to Order Start Time: " + s3 + " End Time: " + e3;//perf check
}
else//perf check
{
strmsg = "";//perf check
}
}
//Commented Code for Performance Tuning: <By JQ486>
/*if(sReqGen == "Execute");
{
if(WriteError == "Display") //JQ487: added new condition as per defect 572 on 08/03/11
{
TheApplication().RaiseErrorText("Parts Request created, Write in
Product cannot be replaced."); //JQ487: added new condition as per defect 572 on 08/03/11
}
else
{*/
TheApplication().RaiseErrorText("Parts Request created. Review & submit." + "\n" + strmsg);//perf check
/*}
}*/
return(CancelOperation);
}
}
catch(e)
{
//TheApplication().Trace("Error Message : " + e.toString() + e.errCode);
//TheApplication().TraceOff(); throw(e);
}
return(ContinueOperation);
}
var aAllocQtyArr = new Array;
function GetItemQty(sProdId)
{
try
{
if(sProdId != null || sProdId != "")
{
for(var i = 0; i < aProdArr.length; i++)
{
if(aProdArr[i] == sProdId)
{
return i;
}
}
}
}
24
function GetLineItemsInfo(sQuoteNum)
{
/*CMI DBU:JQ487:15/Apr/2011: The Below function is used to Query on Part Tracker BC to
valdate that Picked Qty on
Part Tracker Record is Less than sum of Quoted Qty and Qty request on current revision. */
try
{
var iCount = 0;
var IsActivityRec;
var IsPartTrackRec;
var oBO = TheApplication().GetBusObject("Action");
var oBCAction = oBO.GetBusComp("Action");
var oBCPartTracker = oBO.GetBusComp("FS Activity Parts Movement");
with(oBCAction)
{
ActivateField("CMI Quote Number");
ActivateField("Type");
SetViewMode(AllView);
ClearToQuery();
SetSearchSpec("CMI Quote Number",sQuoteNum);
SetSearchSpec("Type", TheApplication().InvokeMethod("LookupValue","TODO_TYPE","Parts Tracker"));
ExecuteQuery(ForwardOnly);
IsActivityRec = FirstRecord();
if(IsActivityRec)
{
var ActivityId = GetFieldValue("Id");
with(oBCPartTracker)
{
SetViewMode(AllView);
ActivateField("Product Name");
ActivateField("Product Id");
ActivateField("CMI Parts Allocated");
ActivateField("CMI Quoted Quantity");
ClearToQuery();
//SetSearchSpec("Product Id", sProdId);
ExecuteQuery(ForwardOnly);
var sPCNextRecord = FirstRecord();
while(sPCNextRecord)
{
//Implementing the array logic for performance tuning.By jq486.
aProdArr[iCount] = GetFieldValue("Product Id");
aQuotedQtyArr[iCount] = GetFieldValue("CMI Quoted Quantity");
aAllocQtyArr[iCount] = GetFieldValue("CMI Parts Allocated");
iCount++;
sPCNextRecord = NextRecord();
}
}
}//End of while(IsActivityRec)
}//End of with(oBCAction)
25
}//End of try
}
function ProductCheck(sPrdDesc)
{
try
{
var oBO = TheApplication().ActiveBusObject();
var oBCInterProd = oBO.GetBusComp("Internal Product");
with(oBCInterProd)
{
SetViewMode(AllView);
ActivateField("Product");
ActivateField("Name");
ClearToQuery();
SetSearchSpec("Name", sPrdDesc);
ExecuteQuery(ForwardOnly);
var isRec1 = FirstRecord();
if(isRec1)
{
sProdId1 = GetFieldValue("Id");
sProdName1 = GetFieldValue("Name");
}
else
{
WriteError = "Display"; //JQ487: added new condition as per defect 572 on
08/03/11
}
}
}
catch(e)
{
//TheApplication().Trace("Error Message : " + e.toString() + e.errCode);
//TheApplication().TraceOff();
throw(e);
}
}
function QuoteToOrder(sQuoteId)
{
try
{
26
var sSubInv = TheApplication().InvokeMethod("LookupValue",
"CMI_SUB_INVENTORY", "ServiceWIP");
var sLineType = TheApplication().InvokeMethod("LookupValue", "CMI_LINE_TYPE",
"Service Part Request Line");
var sSourceType = TheApplication().InvokeMethod("LookupValue",
"CMI_QUOTE_SRC_TYPE", "STK");
with (oBCOrder)
{
SetViewMode(AllView);
ActivateField("Quote Id");
ActivateField("CMI Order Type");
ActivateField("Service Request Id");
ActivateField("CMI Business Unit");
ClearToQuery();
SetSearchSpec("Quote Id", sQuoteId);
ExecuteQuery(ForwardBackward);
//var iCount = CountRecords();
var sOrdId = GetFieldValue("Id");
/*Commented by JQ487 as Signal changed */
//var sOrdtype = TheApplication().InvokeMethod("LookupValue",
"FS_ORDER_TYPE", "Parts Request");
//SetFieldValue("CMI Order Type", sOrdtype);
SetFieldValue("Service Request Id", sSRNum);
SetFieldValue("CMI Business Unit", sBU);
WriteRecord();
}
with (oBCOrderItem)
{
SetViewMode(AllView);
ActivateField("Order Header Id");
ActivateField("Product Id");
ActivateField("Product Type");
ActivateField("Product");
ActivateField("CMI Revise Flag");
ActivateField("Quantity Requested");
ActivateField("CMI Quantity Difference");
ActivateField("CMI Sub Inventory");
ActivateField("CMI Line Type");
ActivateField("CMI Source Type");
ActivateField("CMI Write In Error Flag");
ClearToQuery();
SetSearchSpec("Order Header Id", sOrdId);
ExecuteQuery(ForwardBackward);
//var iCount1 = CountRecords();
var isRec = FirstRecord();
while(isRec)
{
sProdType = GetFieldValue("Product Type");
sProdName = GetFieldValue("Product");
sRevFlg = GetFieldValue("CMI Revise Flag");
var sQty = GetFieldValue("Quantity Requested");
27
var sQtyCalc = GetFieldValue("CMI Quantity Difference");
SetFieldValue("CMI Sub Inventory", sSubInv);
SetFieldValue("CMI Line Type", sLineType);
SetFieldValue("CMI Source Type", sSourceType);
WriteRecord();
if(sProdName == sProdVal3)
{
sPrdDesc = GetFieldValue("Write-In Product");
ProductCheck(sPrdDesc);
var sPicklistProdBC = oBCOrderItem.GetPicklistBusComp("Product");
with(sPicklistProdBC)
{
SetViewMode(AllView);
ClearToQuery();
SetSearchSpec("Id", sProdId1);
ExecuteQuery(ForwardBackward);
if(FirstRecord())
{
Pick();
}
}
if(WriteError == "Display")
{
SetFieldValue("CMI Write In Error Flag", "Y");
WriteRecord();
}
isRec = NextRecord();
}
// else
// {
if(sRevFlg == "Y")
{
/*Commented by JQ487 as Signal changed */
/*if((sProdType != sProdVal1) && (sProdType != sProdVal2))
{
DeleteRecord();
isRec = FirstRecord();
}
else*/
if ((sQty == sQtyCalc)||(sQtyCalc == ""))
{
DeleteRecord();
isRec = FirstRecord();
}
else
{
SetFieldValue("Quantity Requested", sQtyCalc);
SetFieldValue("CMI Revise Flag", "N");
WriteRecord();
isRec = NextRecord();
28
}
}
else
{
isRec = NextRecord();
}
// }
/*else
{
if((sProdType != sProdVal1) && (sProdType != sProdVal2))
{
DeleteRecord();
}
}
function QuoteValidation(sQuoteId)
{
try
{
30
//SetSearchExpr("[CMI ATP Requested Quantity] > 0");
ExecuteQuery(ForwardBackward);
//var iCount1 = CountRecords();
var isRec = FirstRecord();
while(isRec)
{
sProdType = GetFieldValue("Product Type");
sProdId = GetFieldValue("Product Id");
sRevFlg = GetFieldValue("CMI Revise Flag");
var sQty = GetFieldValue("Quantity Requested");
var sQtyCal = GetFieldValue("CMI Quantity Requested");
sProdName = GetFieldValue("Product");
sSerialized = GetFieldValue("CMI Serialized Flag");
if (sRevFlg == "Y")
{
//if((sProdType == sProdVal1) || (sProdType == sProdVal2))
if((sProdType != sProdVal1) && (sProdType != sProdVal2))
{
/*if (sSerialized != "Y") //<jq487>
{
//SerialCheck(sProdId);//<jq487> added to accomodate defect 657
iQtyIdx = GetItemQty(sProdId);
sQuantQuoted = aQuotedQtyArr[iQtyIdx];
sPickQuan = aAllocQtyArr[iQtyIdx];
sQtyDiff = ToNumber(sQuantQuoted) + ToNumber(sQty
if (sQtyDiff <= ToNumber(sPickQuan))//<jq487> added to accomodate defect 657
{
iCount = 0;//<jq487> added to accomodate defect 657
}
else
{
iCount = 1;//<jq487> added to accomodate defect 657
}
}*/ //commented by <JQ487> as function not needed here but in else block
if (sQty != sQtyCal)
{
//Commented Code for Performance Tuning: <By JQ486>
//sUpdQty = ToNumber(sQty) - ToNumber(sQtyCal);
sUpdQty = GetFieldValue("CMI ATP Requested Quantity");
if (sUpdQty > '0')
{
//Commented Code for Performance Tuning: <By JQ486>
//SetFieldValue("CMI Quantity Difference", sUpdQty);
//WriteRecord();
counter = 1;
}
else
{
counter = 0;
31
}
}
}
}//end if
else
{
//if((sProdType == sProdVal1) || (sProdType == sProdVal2))
//iCount = 1;//<jq487> added to accomodate defect 657
if((sProdType != sProdVal1) && (sProdType != sProdVal2))
{
if(sFlg == "Y")//added by <JQ487> for defect 657
{
f (sSerialized != "Y") //<jq487>
{
//SerialCheck(sProdId
iQtyIdx = GetItemQty(sProdId);
sQuantQuoted = aQuotedQtyArr[iQtyIdx];
sPickQuan = aAllocQtyArr[iQtyIdx];
sQtyDiff = ToNumber(sQuantQuoted) + ToNumber(sQty
if (sQtyDiff <= ToNumber(sPickQuan))//<jq487>
{
sFlg1 = 0;//<jq487> added to accomodate defect 657
SetFieldValue("CMI Parts Check", "Y");//<jq487> added to accomodate defect 657
}
else
{
sFlg2 = 1;//<jq487> added to accomodate defect 657
SetFieldValue("CMI Parts Check", "N
SetFieldValue("CMI Quantity Requested", sPickQuan
}
}
else//added by <JQ487> for defect 657
{
iCount = 1;//added by <JQ487> for defect 657
}
}
else//added by <JQ487> for defect 657
{
iCount = 1;//added by <JQ487> for defect 657
}
/* if(sProdName == sProdVal3)
{
var sProdSta = GetFieldValue("CMI Write-In Status Code");
var sStaCod = TheApplication().InvokeMethod("LookupValue",
"CMI_ONEOFF_STATUS", "SUCCESS");
if(sProdSta == sStaCod)
{
counter = 1;
}
}
else
32
{*/
counter = 1;
}
}
WriteRecord();
}
isRec = NextRecord();
}//end while
//if ((counter == 0)||(iCount == 0))//<
if ((counter == 0)||((sFlg1 == 0) && (sFlg2 == 0 {
//TheApplication().RaiseErrorText("Parts Request cannot be generated as there are no
parts associated to Quote");
sRetCan = "Allow";
}
}//end with
}//end if
}//end With
}// end try
catch(e)
{
//TheApplication().Trace("Error Message : " + e.toString() + e.errCode);
//TheApplication().TraceOff(); throw(e);
}
}
function SerialCheck(sProdId)
{
try
{
var IsActivityRec;
var IsPartTrackRec;
var oBO = TheApplication().GetBusObject("Action");
var oBCAction = oBO.GetBusComp("Action");
var oBCPartTracker = oBO.GetBusComp("FS Activity Parts Movement");
with(oBCAction)
{
ActivateField("CMI Quote Number");
ActivateField("Type");
SetViewMode(AllView);
ClearToQuery();
SetSearchSpec("CMI Quote Number",sQuoteNum);
SetSearchSpec("Type", TheApplication().InvokeMethod("LookupValue","TODO_TYPE","Parts Tracker"));
ExecuteQuery(ForwardOnly);
IsActivityRec = FirstRecord();
if(IsActivityRec)
{
var ActivityId = GetFieldValue("Id");
with(oBCPartTracker)
{
SetViewMode(AllView);
33
ActivateField("Product Name");
ActivateField("Product Id");
ActivateField("CMI Parts Allocated");
ActivateField("CMI Quoted Quantity");
ClearToQuery();
SetSearchSpec("Product Id", sProdId);
ExecuteQuery(ForwardOnly);
var sPCNextRecord = FirstRecord();
if(sPCNextRecord)
{
sQuantQuoted = GetFieldValue("CMI Quoted Quantity");
sPickQuan = GetFieldValue("CMI Parts Allocated");
}
}
}//End of while(IsActivityRec)
}//End of with(oBCAction)
}//End of try
}//end of function
CMI QUOTE CREATION BS
function Service_PreInvokeMethod (MethodName, Inputs, Outputs)
{
if (MethodName == "CreateActivityPlan")
{
sQuoteId = TheApplication().GetProfileAttr("QuoteId");
sTemplateName = Inputs.GetProperty("Context");
var bothis = TheApplication().ActiveBusObject();
switch(bothis.Name())
{
case "Service Request" :
CreateActivityPlan(sTemplateName,sQuoteId);
break;
case "Quote" :
CreateActivityPlanQuote(sTemplateName,sQuoteId);
break;
default:
break;
}
return(CancelOperation);
}
if (MethodName == "UpdateActivityPlanField")
{
sQuoteId = TheApplication().GetProfileAttr("QuoteId");
sTemplateName = Inputs.GetProperty("Context");
UpdateActivityPlanField(sTemplateName,sQuoteId);
return(CancelOperation);
}
return (ContinueOperation);
}
var sTemplateName;
var sQuoteId;
34
function CreateActivityPlan(sTemplateName,sQuoteId)
{
try
{
var oBO = TheApplication().ActiveBusObject();
//var oBCSR = oBO.GetBusComp("Service Request");//Commented:James
//var SRId = oBCSR.GetFieldValue("Id");//Commented:James
var oBCActivityPlan = oBO.GetBusComp("Activity Plan");
var oBCActivityPlanAction = oBO.GetBusComp("Activity Plan Action");
var oBCAction = oBO.GetBusComp("Action");
var oBCQuote = oBO.GetBusComp("Quote");
oBCQuote.ActivateField("Revision");
//var sQuoteId = oBCQuote.GetFieldValue("Id");//Commented:JQ486
//TheApplication().SetProfileAttr("QuoteId",sQuoteId);
//var sQuoteNum = oBCQuote.GetFieldValue("Quote Number");//Commented:JQ486
var sTemplatePickBC;
var isPickBCRec;
var sQuoteId_Temp = TheApplication().GetProfileAttr("CMIRevisionNum");
if(sQuoteId_Temp == "1")
{
DefaultSourceLoc(sQuoteId);
}
/* with(oBCSR)
{
SetViewMode(AllView);
ClearToQuery();
SetSearchSpec("Id",SRId);
ExecuteQuery(ForwardBackward);
if(FirstRecord())
{*/
with(oBCActivityPlan)
{
NewRecord(NewAfter);
sTemplatePickBC = oBCActivityPlan.GetPicklistBusComp("Template");
with(sTemplatePickBC)
{
SetViewMode(AllView);
ClearToQuery();
SetSearchSpec("Name",sTemplateName);
ExecuteQuery(ForwardBackward);
isPickBCRec = FirstRecord();
if(isPickBCRec)
{
Pick();
}
}
WriteRecord();
oBCActivityPlan.ActivateField("Activity UID");
var sActivityId = oBCActivityPlan.GetFieldValue("Activity UID");
TheApplication().SetProfileAttr("CMIActivityAttribute",sActivityId);
}
35
//}
//}
}// end try
catch(e)
{
TheApplication().Trace("Error Message : " + e.toString() + e.errCode);
TheApplication().TraceOff(); throw(e);
}
}
function CreateActivityPlanQuote(sTemplateName,sQuoteId)
{
var bothis = TheApplication().ActiveBusObject();
//var sRateListId = TheApplication().GetProfileAttr("CMI Rate List Id");//add by woody for GL
var sRateListId;//added by woody
var sCurrencyCode//added by woody
var oBCQuote = bothis.GetBusComp("Quote");
var oBCDivision = bothis.GetBusComp("Internal Division");//added by woody
oBCQuote.ActivateField("CMI Primary Division Id");
var sQuoteId_Temp = TheApplication().GetProfileAttr("CMIRevisionNum");
var sSRId = oBCQuote.GetFieldValue("Service Request Id");//because this field is link specfication no
need to active
var sDivisionId = oBCQuote.GetFieldValue("CMI Primary Division Id");//added by woody
if(sQuoteId_Temp == "1")
{
DefaultSourceLoc(sQuoteId);
}
var boSR = TheApplication().GetBusObject("Service Request");
var bcSR = boSR.GetBusComp("Service Request");
var oBCActivityPlan = boSR.GetBusComp("Activity Plan");
var oBCActivityPlanAction = boSR.GetBusComp("Activity Plan Action");
var isRecord;
var isQuoteRec;//added by woody
var isDivisionRec;//added by woody
with(oBCQuote)
{
SetViewMode(AllView);
ClearToQuery();
SetSearchSpec("Id",sQuoteId);
ExecuteQuery(ForwardBackward);
isQuoteRec = FirstRecord()
if(isQuoteRec)
{
with(oBCDivision)
{
SetViewMode(AllView);
ActivateField("CMI Rate List Id");
ActivateField("Currency Code");
ClearToQuery();
SetSearchSpec("Id",sDivisionId);
ExecuteQuery(ForwardBackward);
36
isDivisionRec = FirstRecord()
if(isDivisionRec)
{
sRateListId = GetFieldValue("CMI Rate List Id");
sCurrencyCode = GetFieldValue("Currency Code");
}
}
}
}
with(bcSR)
{
SetViewMode(AllView);
ClearToQuery();
SetSearchSpec("Id",sSRId);
ExecuteQuery(ForwardBackward);
if(FirstRecord())
{
with(oBCActivityPlan)
{
NewRecord(NewAfter);
var sTemplatePickBC =
oBCActivityPlan.GetPicklistBusComp("Template");
with(sTemplatePickBC)
{
SetViewMode(AllView);
ClearToQuery();
SetSearchSpec("Name",sTemplateName);
ExecuteQuery(ForwardBackward);
if(FirstRecord())
{
Pick();
}
}
WriteRecord();
oBCActivityPlan.ActivateField("Activity UID");
var sActivityId = oBCActivityPlan.GetFieldValue("Activity UID");
TheApplication().SetProfileAttr("CMIActivityAttribute",sActivityId);
}
function UpdateActivityPlanField(sTemplateName,sQuoteId)
{
try
{
var oBO = TheApplication().ActiveBusObject();
//var sRateListId = TheApplication().GetProfileAttr("CMI Rate List Id");//add by woody for GL
var sRateListId;
var oBCActivityPlan = oBO.GetBusComp("Activity Plan");
var sActivityId = TheApplication().GetProfileAttr("CMIActivityAttribute");
var oBCActivityPlanAction = oBO.GetBusComp("Activity Plan Action");
var oBCAction = oBO.GetBusComp("Action");
var oBCQuote = oBO.GetBusComp("Quote");
var oBCDivision = oBO.GetBusComp("Internal Division");//added by woody
oBCQuote.ActivateField("CMI Primary Division Id");
//var sDivisionId = oBCQuote.GetFieldValue("CMI Primary Division Id");//added by woody //
commented by jx050(pravin)
//var sQuoteId = oBCQuote.GetFieldValue("Id");//Commented:JQ486
//var sQuoteNum = oBCQuote.GetFieldValue("Quote Number");//Commented:JQ486
var sTemplatePickBC;
var isPickBCRec;
var isRecord;
var sCurrActivityId;
var isQuoteRec;//added by woody
var isDivisionRec;//added by woody
var sCurrencyCode//added by woody
with(oBCQuote)
39
{
SetViewMode(AllView);
ClearToQuery();
SetSearchSpec("Id",sQuoteId);
ExecuteQuery(ForwardOnly);
isQuoteRec = FirstRecord();
if(isQuoteRec)
{
var sDivisionId = oBCQuote.GetFieldValue("CMI Primary Division Id");//added by jx050(Pravin)
with(oBCDivision)
{
SetViewMode(AllView);
ActivateField("CMI Rate List Id");
ActivateField("Currency Code");
ClearToQuery();
SetSearchSpec("Id",sDivisionId);
ExecuteQuery(ForwardOnly);
isDivisionRec = FirstRecord();
if(isDivisionRec)
{
sRateListId = GetFieldValue("CMI Rate List Id");
sCurrencyCode = GetFieldValue("Currency Code");
}
}
}
}
if(sTemplateName == "Part Tracker Template")
{
with(oBCActivityPlanAction)
{
SetViewMode(AllView);
ActivateField("CMI Quote Id");
ActivateField("Parent Activity Id");
ClearToQuery();
SetSearchSpec("Parent Activity Id",sActivityId);
ExecuteQuery(ForwardBackward);
isRecord = FirstRecord();
if(isRecord)
{
SetFieldValue("CMI Quote Id", sQuoteId);
WriteRecord();
}
}
}
if(sTemplateName == "Time Tracker Template")
{
with(oBCActivityPlanAction)
{
SetViewMode(AllView);
40
ActivateField("Parent Activity Id");
ActivateField("CMI Quote Id");
ActivateField("CMI Rate List Id");
ActivateField("Currency Code");
ClearToQuery();
SetSearchSpec("Parent Activity Id",sActivityId);
ExecuteQuery(ForwardBackward);
isRecord = FirstRecord();
if(isRecord)
{
SetFieldValue("CMI Quote Id", sQuoteId);
SetFieldValue("CMI Rate List Id", sRateListId);//add by woody for GL
SetFieldValue("Currency Code", sCurrencyCode);//add by woody for GL
WriteRecord();
}
}// end Activity plan action BC
}
}// end try
}
CMI CHECK DISCOUNT PERCENT
//JX050
function Service_PreInvokeMethod (MethodName, Inputs, Outputs)
{
if (MethodName == "Check Discount Percent")
{
var oBO;
var oBCQIW;
var PercentAll;
var Percent;
var TotPercent=0;
oBO = TheApplication().ActiveBusObject();
oBCQIW = oBO.GetBusComp("CMI Quote Item Warranty");
PercentAll = oBCQIW.GetFieldValue("CMI Total Discount Percent");
Percent = TheApplication().GetProfileAttr("percentcovered");
41
}
else
if(((TheApplication().ActiveViewName() == "CMI Parts Quote Line Item View")||
(TheApplication().ActiveViewName() == "CMI Labor Quote Line Item View")||
(TheApplication().ActiveViewName() == "CMI Misc Quote Line Item View")) &&
(TheApplication().GetProfileAttr("NewWarrantyRecord") != "Y"))
{
oBO = TheApplication().ActiveBusObject();
oBCQIW = oBO.GetBusComp("CMI Quote Item Warranty");
PercentAll = oBCQIW.GetFieldValue("CMI Total Discount Percent");
Percent = TheApplication().GetProfileAttr("percentcovered");
var Oldpercent = TheApplication().GetProfileAttr("OldPercentCovered");
TotPercent = ToNumber(Percent) + ToNumber(PercentAll) - ToNumber(Oldpercent);
if(TotPercent > 100)
{
TheApplication().RaiseErrorText("Total Percent of all warranties cannot be greater than 100");
}
}
return (CancelOperation);
}
return (ContinueOperation);
}
CMI ADD CORE PRODUCT
function Service_PreInvokeMethod (MethodName, Inputs, Outputs)
{
if (MethodName == "AddCore")
{
//AddCore(sCoreProdId,sQuoteId,sQId,sSeq);
AddCore(Inputs,Outputs);
return(CancelOperation);
}
return (ContinueOperation);
}
function AddCore(Inputs,Outputs)//asCoreProdId,asQuoteId,sQId,sSeq)
{
try
{
var asCoreProdId = Inputs.GetProperty("CMI Recon Pro Id");
var asQuoteId = Inputs.GetProperty("Quote Item Id");
var sQId = Inputs.GetProperty("Quote Id");
var sSeq = Inputs.GetProperty("Sequence No");
var sPriceList = Inputs.GetProperty("Price List");
var sUOM = Inputs.GetProperty("UOM");
var sType = Inputs.GetProperty("Type");
var oProBO = TheApplication().GetBusObject("Admin ISS Product Definition");
var oProBC = oProBO.GetBusComp("Product Recommendation");
with(oProBC)
{
ActivateField("Recommended Product ID");
42
ActivateField("Parent Product ID");
ClearToQuery();
SetViewMode(AllView);
SetSearchSpec("Parent Product ID", asCoreProdId);
SetSearchSpec("UMS Type", 'Core');
ExecuteQuery(ForwardOnly);
var sRecord = FirstRecord();
var lsSequence = ToNumber(sSeq) + 1;
while(sRecord)
{
var sCoreId = GetFieldValue("Recommended Product ID");
var oQuoteO = TheApplication().GetBusObject("Quote");
var oQuoteBC = oQuoteO.GetBusComp("Quote Item");
with(oQuoteBC)
{
NewRecord(NewAfter)
SetFieldValue("Line Number", lsSequence);
SetFieldValue("Quote Id",sQId);
SetFieldValue("Product Id",sCoreId);
SetFieldValue("Parent Quote Item Id", asQuoteId);
SetFieldValue("Root Quote Item Id", asQuoteId);
SetFieldValue("CMI Line Type", TheApplication().InvokeMethod("LookupValue",
"CMI_LINE_TYPE", "Recon Line type"));
SetFieldValue("Item Price List Id", sPriceList);
SetFieldValue("CMI Unit of Measure", sUOM);
WriteRecord();
if(sType == TheApplication().InvokeMethod("LookupValue", "QUOTE_TYPE", "Service Quote"))
{
NewRecord(NewAfter)
lsSequence = lsSequence + 1;
SetFieldValue("Line Number", lsSequence);
SetFieldValue("Quote Id",sQId);
SetFieldValue("Product Id",sCoreId);
SetFieldValue("Parent Quote Item Id", asQuoteId);
SetFieldValue("Root Quote Item Id", asQuoteId);
//SetFieldValue("CMI Line Type", 'Recon Return Line type');
-commented and used LookupValue as per TS review - JW919 17/5/2011
SetFieldValue("CMI Line Type",
TheApplication().InvokeMethod("LookupValue", "CMI_LINE_TYPE", "Recon Return Line type"));
SetFieldValue("Item Price List Id", sPriceList);
SetFieldValue("CMI Unit of Measure", sUOM);
WriteRecord();
}
}
lsSequence = lsSequence + 1;
sRecord = NextRecord();
}
}
var oBS = TheApplication().GetService("SIS OM PMT Service");
var psIO = TheApplication().NewPropertySet();
var psOP = TheApplication().NewPropertySet();
43
psIO.SetProperty("Business Object Name", "Quote");
psIO.SetProperty("Business Component Name", "Quote Item");
oBS.InvokeMethod("Refresh Business Component",psIO,psOP);
}
return (ContinueOperation);
}
function ConcatTechName(Inputs, Outputs)
{
try
{
var sName = "";
var sSRId = Inputs.GetProperty("SRId");
Outputs.SetProperty("CatName","");
if(sSRId == "") return;
var bo =TheApplication().GetBusObject("Action");
var bc = bo.GetBusComp("Action");
with (bc)
{ //
ClearToQuery();
SetViewMode(AllView);
var sExpr = "[Activity SR Id] = '"+sSRId+"' AND [Type] = '"+
TheApplication().InvokeMethod("LookupValue","TODO_TYPE","Service Labor")
+ "' AND [Status] <> '" +
TheApplication().InvokeMethod("LookupValue","EVENT_STATUS", "Unscheduled")
+ "' AND [Status] <> '" +
TheApplication().InvokeMethod("LookupValue","EVENT_STATUS", "Scheduled")
+ "' AND [Status] <> '" +
TheApplication().InvokeMethod("LookupValue","EVENT_STATUS", "Completed")
+ "' AND [Status] <> '" +
TheApplication().InvokeMethod("LookupValue","EVENT_STATUS", "Done")
+ "' AND [Status] <> '" +
TheApplication().InvokeMethod("LookupValue","EVENT_STATUS", "Cancelled")
+"'";
SetSearchExpr(sExpr);
ExecuteQuery(ForwardOnly);
var bHasRecord = FirstRecord();
while(bHasRecord)
44
{
var sTempName = GetFieldValue("CMI Owner FullName");
if(sTempName != "")
{
if(sName == "")
sName = sTempName
else
sName = sName +"; "+ sTempName;
}
bHasRecord = NextRecord();
}
Outputs.SetProperty("CatName", sName);
}
}
if (MethodName == "CreateQuote")
{
sQuoteId = TheApplication().GetProfileAttr("Quote Id");
CreateActivity(sQuoteId);
return(CancelOperation);
}
if(MethodName == "MailToOwner")
{
MailToOwner(Inputs, Outputs);
return CancelOperation;
}
if(MethodName == "SearchFolloUpActivity")
{
SearchFolloUpActivity(Inputs, Outputs);
return CancelOperation;
}
return (ContinueOperation);
}
var sQuoteId;
function CreateActivity(sQuoteId)
45
{
try
{
var oBO = TheApplication().GetBusObject("Quote");
var oBCAction = oBO.GetBusComp("Action (Quote Order)");//JQ486:Added Correct BC
var oBCQuote = oBO.GetBusComp("Quote");
var sQType1 = TheApplication().InvokeMethod("LookupValue", "QUOTE_TYPE", "Wholegoods Quote");
var sQtype2 = TheApplication().InvokeMethod("LookupValue", "QUOTE_TYPE", "Parts Quote");
var sQuoteType = TheApplication().InvokeMethod("LookupValue", "QUOTE_TYPE", "Service Quote");
var sActType = TheApplication().InvokeMethod("LookupValue", "TODO_TYPE", "Quote Follow-up");
var sCalcVar;//JQ486:Declared New Variable
var OwnerName;//JQ486:05Jan2011, Added Script.
var sSalesRepPickBC;//JQ486:05Jan2011, Added Script.
var ldCurrDate;//JW918 07.04.11.Defect 490
var lsCurrDate;
with(oBCQuote)
{
SetViewMode(AllView);
ActivateField("CMI Status As Of Date Calc");
ActivateField("Quote Display Type");
ActivateField("Sales Team");
ClearToQuery();
SetSearchSpec("Id",sQuoteId);
ExecuteQuery(ForwardBackward);
var iCount = CountRecords();
var sType = GetFieldValue("Quote Display Type");
sCalcVar = GetFieldValue("CMI Status As Of Date Calc");//JQ486:Getting the Calculated Value
OwnerName = GetFieldValue("Sales Team");//JQ486:05Jan2011, Added Script.
if(FirstRecord())
{
// if((sType == sQType1) || (sType == sQtype2))
// {
with(oBCAction)
{
ActivateField("Type");
ActivateField("Planned");
ActivateField("Primary Owner Id");//JQ486:05Jan2011, Added Script.
ActivateField("CMI Owner FullName");
ActivateField("Due");
//jw918 07.04.11 Defect 490.To check for existing followup act
SetViewMode(AllView);
ClearToQuery();
SetSearchSpec("Quote Id", sQuoteId);
SetSearchSpec("Type", "Quote Follow-up");
ExecuteQuery();
if(FirstRecord())
{
if(sType == sQuoteType) //jw918 07.04.11 Defect 490.
{
ldCurrDate = GetNewDate();
ldCurrDate.setDate(ldCurrDate.getDate()+2);
46
lsCurrDate = DateToString(ldCurrDate);
SetFieldValue("Due",lsCurrDate);
}
else
{
ldCurrDate = GetNewDate();
ldCurrDate.setDate(ldCurrDate.getDate()+7);
lsCurrDate = DateToString(ldCurrDate);
SetFieldValue("Due",lsCurrDate);
}
WriteRecord();
}
else
{
NewRecord(NewAfter);
SetFieldValue("Type",sActType);//JQ486:Setting Type Value
SetFieldValue("Planned",sCalcVar);//JQ486:Setting Started
ValuesTemplatePickBC = oBCActivityPlan.GetPicklistBusComp("Template");
if(sType == sQuoteType) //jw918 07.04.11 Defect 490.
{
ldCurrDate = GetNewDate();
ldCurrDate.setDate(ldCurrDate.getDate()+2);
lsCurrDate = DateToString(ldCurrDate);
SetFieldValue("Due",lsCurrDate);
}
else
{
ldCurrDate = GetNewDate();
ldCurrDate.setDate(ldCurrDate.getDate()+7);
lsCurrDate = DateToString(ldCurrDate);
SetFieldValue("Due",lsCurrDate);
}
SalesRepPickBC = oBCAction.GetPicklistBusComp("CMI Owner FullName");
with(sSalesRepPickBC)
{
SetViewMode(AllView);
ClearToQuery();
SetSearchSpec("Login Name",OwnerName);
ExecuteQuery(ForwardBackward);
var isPickBCRec = FirstRecord();
if(isPickBCRec)
{
Pick();
}
}
WriteRecord();
}
var sBS = TheApplication().GetService("SIS OM PMT Service");
var sIP = TheApplication().NewPropertySet();
var sOP = TheApplication().NewPropertySet();
sIP.SetProperty("Business Object Name","Quote");
47
sIP.SetProperty("Business Component Name","Quote");
sBS.InvokeMethod("Refresh Business Component",sIP,sOP);
TheApplication().SetProfileAttr("CMIFollowupActionId", GetFieldValue("Id"));
}//end of with
// }
}
}
}// end try
}
function DateToString(adDate)
{
// fetching day, month, year, hour min and sec and constructing the date string
var lsMonth = ToString(adDate.getMonth() + 1);
var lsDay = ToString(adDate.getDate());
var lsHours = ToString(adDate.getHours());
var lsMinutes = ToString(adDate.getMinutes());
var lsSeconds = ToString(adDate.getSeconds());
if (lsMonth.length == 1)
{
lsMonth = "0" + lsMonth;
}
if (lsDay.length == 1)
{
lsDay = "0" + lsDay;
}
if (lsHours.length == 1)
{
lsHours = "0" + lsHours;
}
if (lsMinutes.length == 1)
{
lsMinutes = "0" + lsMinutes;
}
if (lsSeconds.length == 1)
{
lsSeconds = "0" + lsSeconds;
}
if (lsHours == "00" && lsMinutes == "00" && lsSeconds == "00")
return (lsMonth +"/"+ lsDay +"/" + adDate.getFullYear())
else
return (lsMonth +"/"+ lsDay +"/" + adDate.getFullYear() +" "+lsHours+":"+lsMinutes+":"+lsSeconds);
}
function GetNewDate()
{
try
{
var ldcurrtm = Clib.localtime(Clib.time());
var lsmonth = ldcurrtm.tm_mon + 1;
48
var lsyear = ldcurrtm.tm_year + 1900;
var lsday = ldcurrtm.tm_mday;
var lshour = ldcurrtm.tm_hour;
var lsmin = ldcurrtm.tm_min;
var lssec = ldcurrtm.tm_sec;
var lsfulldate = lsmonth + '/' + lsday + '/' + lsyear + ' ' + lshour + ':' + lsmin + ':' + lssec;
var lsnewdate = new Date(lsfulldate);
// return(lsnewdate);
}
return(lsnewdate);
}
function MailToOwner(sActionId)
{
try
{
/* var context_string = Inputs.GetProperty("Context");
var context_array = context_string.split(", ");
var sProfile = context_array[1];
sProfile = sProfile.replace(/\"/g,'');
if(sProfile == "") sProfile = "DBUNextGen_Dev";
var sPackageList = context_array[3];
sPackageList = sPackageList.replace(/\"/g,'');
if(sPackageList == "") sPackageList = "CMI Parts Quote Approval Notification";*/
var sProfile = "DBUNextGen_Dev";
var sPackageList = "CMI Follow Up Activity Email";
// var sActionId = TheApplication().GetProfileAttr("CMIFollowupActionId");
if(sActionId == "") return;
var bs = TheApplication().GetService("Outbound Communications Manager");
var psIn = TheApplication().NewPropertySet();
var psOut = TheApplication().NewPropertySet();
psIn.SetProperty("RecipientGroup","CMI Activity Owner");
psIn.SetProperty("CommProfileOverride",sProfile);
psIn.SetProperty("SourceIdList",sActionId);
psIn.SetProperty("PackageNameList",sPackageList);
bs.InvokeMethod("CreateRequest", psIn, psOut);
}
}
function SearchFolloUpActivity()
{
try
{
var sActBo = TheApplication().GetBusObject("Action");
var sActBC = sActBo.GetBusComp("Action");
var lsType = TheApplication().InvokeMethod("LookupValue", "TODO_TYPE", "Quote Follow-up");
var lsStatus = TheApplication().InvokeMethod("LookupValue", "EVENT_STATUS", "Done");
var ldcurrtm = Clib.localtime(Clib.time());
var lsmonth = ldcurrtm.tm_mon + 1;
var lsyear = ldcurrtm.tm_year + 1900;
49
var lsday = ldcurrtm.tm_mday;
var lsCurrentStDate = lsmonth + '/' + lsday + '/' + lsyear + ' ' + "00" + ':' + "00" + ':' + "01";
var lsCurrentEndDate = lsmonth + '/' + lsday + '/' + lsyear + ' ' + "23" + ':' + "59" + ':' + "59";
var lsExpr = "[Type]= '" + lsType + "' AND [Due] >= '" + lsCurrentStDate + "' AND [Due]
<= '" + lsCurrentEndDate + "' AND [Status] <> '" + lsStatus + "' AND [Time Sheet Related Flag] = 'N'";
with(sActBC)
{
ActivateField("Due");
ActivateField("Time Sheet Related Flag");
SetViewMode(AllView);
ClearToQuery()
SetSearchExpr(lsExpr);
ExecuteQuery();
var lsCount = CountRecords();
var lsRecord = FirstRecord();
while(lsRecord)
{
var lsDueDate = GetFieldValue("Due");
var lsId = GetFieldValue("Id");
MailToOwner(lsId);
SetFieldValue("Time Sheet Related Flag","Y");
lsRecord = NextRecord();
}
}
}
}
function UpdateFollowUpActivity()
{
try
{
var lsAccQuoteId = TheApplication().GetProfileAttr("CMI AccQuote Id");
var lsType = TheApplication().InvokeMethod("LookupValue", "TODO_TYPE", "Quote Follow-up");
var lsStatus = TheApplication().InvokeMethod("LookupValue", "EVENT_STATUS", "Done");
var loQuoteBo = TheApplication().GetBusObject("Quote");
var loActBC = loQuoteBo.GetBusComp("Action (Quote Order)");
with(loActBC)
{
SetViewMode(AllView);
ClearToQuery()
SetSearchSpec("Quote Id",lsAccQuoteId);
SetSearchSpec("Type", lsType);
SetSearchSpec("Status", "<>" + "'" + lsStatus + "'");
ExecuteQuery(ForwardOnly);
if(FirstRecord())
{
SetFieldValue("Status",lsStatus);
}
WriteRecord();
}
50
var sBS = TheApplication().GetService("SIS OM PMT Service");
var sIP = TheApplication().NewPropertySet();
var sOP = TheApplication().NewPropertySet();
sIP.SetProperty("Business Object Name","Quote");
sIP.SetProperty("Business Component Name","Quote");
sBS.InvokeMethod("Refresh Business Component",sIP,sOP);
TheApplication().SetProfileAttr("CMI AccQuote Id","");
}
}
CMI ADD ORDER ID TO TRACKER ACTIVITY
function Service_PreInvokeMethod (MethodName, Inputs, Outputs)
{
if (MethodName == "AddOrderId")
{
var sQuoteNumber = Inputs.GetProperty("QuoteNumber");
var sOrderId = Inputs.GetProperty("OrderId");
AddOrderId(sQuoteNumber, sOrderId);
return (CancelOperation);
}
return (ContinueOperation);
}
function AddOrderId(sQuoteNumber, sOrderId)
{
var oBOAction = TheApplication().GetBusObject("Action");
var oBCAction = oBOAction.GetBusComp("Action");
with(oBCAction)
{
var sPartsTracker = TheApplication().InvokeMethod("LookupValue", "TODO_TYPE", "Parts Tracker");
var sTimeTracker = TheApplication().InvokeMethod("LookupValue", "TODO_TYPE", "Service Labor");
SetViewMode(AllView);
ActivateField("Order Id");
ActivateField("CMI Quote Number");
ClearToQuery();
var searchst = "[CMI Quote Number] = '" + sQuoteNumber + "' AND ([Type] = '" +
sPartsTracker + "' OR [Type] = '" + sTimeTracker + "')";
SetSearchExpr(searchst);
//SetSearchSpec("Quote Id", sQuoteNumber); //should be Quote Number, this field is not created yet.
ExecuteQuery(ForwardOnly);
var HasRecord = FirstRecord()
while(HasRecord)
{
SetFieldValue("Order Id",sOrderId);
WriteRecord();
HasRecord = NextRecord();
}
}//end with(oBCAction)
}
CMI BATCH PAYMENT PROCESS BS
function Service_PreInvokeMethod (MethodName, Inputs, Outputs)
51
{
if (MethodName == "BatchCloseProcess")
{
BatchCloseProcess();
return(CancelOperation);
}
if (MethodName == "PaymentVarianceCheck")
{
PaymentVarianceCheck();
return(CancelOperation);
}
if (MethodName == "BatchPaymentCheck")
{
BatchPaymentCheck();
return(CancelOperation);
}
/*if (MethodName == "RefileCheck")
{
RefileCheck();
return(CancelOperation);
}*/
return (ContinueOperation);
}
function BatchCloseProcess()
{
try
{
var oBO = TheApplication().ActiveBusObject();
var oBC = oBO.GetBusComp("CS HH Deposits");
var sBatchId = oBC.GetFieldValue("Id");
var oBOBatch = TheApplication().GetBusObject("HH CG Deposit Payments");
var oBCBatchPaymemt = oBOBatch.GetBusComp("CS HH FS Payments");
var oBOClaim = TheApplication().GetBusObject("CMI Claims");
var oBCClaim = oBOClaim.GetBusComp("INS Claims");
var oBCPayment = oBOClaim.GetBusComp("INS Claims Payments");
var sClaimNumber;
var sClaimId;
var iPayVariance = 0;
var iVarToLevel;
with(oBCBatchPaymemt)
{
InvokeMethod("SetAdminMode", "TRUE");
SetViewMode(AllView);
ActivateField("Payment Status");
ActivateField("Claim #");
ClearToQuery();
SetSearchSpec("Deposit Id", sBatchId);
SetSearchSpec("Payment Status",
TheApplication().InvokeMethod("LookupValue","FUNDRQ_STATUS","Pending"));
ExecuteQuery(ForwardOnly);
var HasRecord = FirstRecord();
52
while (HasRecord)
{
sClaimId = GetFieldValue("Claim Id");
with(oBCClaim)
{
InvokeMethod("SetAdminMode", "TRUE");
SetViewMode(AllView);
ActivateField("CMI Payment Variance Sum");
ActivateField("CMI Variance Tolerance Level");
ActivateField("Status Code");
ClearToQuery();
SetSearchSpec("Id", sClaimId);
ExecuteQuery(ForwardOnly);
if (FirstRecord())
{
iPayVariance = GetFieldValue("CMI Payment Variance Sum");
iVarToLevel = GetFieldValue("CMI Variance Tolerance Level");
if (ToNumber(iVarToLevel) < ToNumber(iPayVariance))
{
SetFieldValue("Status Code",
TheApplication().InvokeMethod("LookupValue","INS_CLAIM_STATUS","Payment Received"));
WriteRecord();
}
else if (ToNumber(iVarToLevel) >= ToNumber(iPayVariance) && Math.abs(ToNumber(iPayVariance))> 0)
{
with(oBCPayment)
{
NewRecord(1);
ActivateField("Payment Amount");
ActivateField("Payment Type Code");
ActivateField("Payment Status");
//ActivateField("CMI Payment Credit Type
SetFieldValue("Payment Amount", iPayVariance);
SetFieldValue("Payment Type Code",
TheApplication().InvokeMethod("LookupValue","CMI_PAYMENT_TYPE","Variance"));
SetFieldValue("CMI Payment Credit Type",
TheApplication().InvokeMethod("LookupValue","CMI_PAY_CDT_TYPE","Consolidate"));
SetFieldValue("Payment Status",
TheApplication().InvokeMethod("LookupValue","FUNDRQ_STATUS","Verified"));
WriteRecord();
}
SetFieldValue("Status Code",
TheApplication().InvokeMethod("LookupValue","INS_CLAIM_STATUS","Closed"));
WriteRecord();
}
else if (ToNumber(iPayVariance) == 0)
{
SetFieldValue("Status Code",
TheApplication().InvokeMethod("LookupValue","INS_CLAIM_STATUS","Closed"));
WriteRecord();
53
}
}
}
SetFieldValue("Payment Status",
TheApplication().InvokeMethod("LookupValue","FUNDRQ_STATUS","Verified"));
WriteRecord();
HasRecord = NextRecord();
}
oBC.InvokeMethod("RefreshBusComp");
}
}
function BatchPaymentCheck()
{
try
{
var oBO = TheApplication().ActiveBusObject();
var oBCBatch = oBO.GetBusComp("CS HH Deposits");
var sBatchId = oBCBatch.GetFieldValue("Id");
var oBOBatch = TheApplication().GetBusObject("HH CG Deposit Payments");
var oBCBatchPaymemt = oBOBatch.GetBusComp("CS HH FS Payments");
var oBOClaim = TheApplication().GetBusObject("CMI Claims");
var oBCClaim = oBOClaim.GetBusComp("INS Claims");
var oBCClaimPayment = oBOClaim.GetBusComp("INS Claims Payments");
var iClaimNumber;
var iClaimId;
var sPayVariance = 0;
var sVarToLevel;
with(oBCBatchPaymemt)
{
InvokeMethod("SetAdminMode", "TRUE");
SetViewMode(AllView);
ActivateField("Payment Status");
ActivateField("Claim #");
ClearToQuery();
SetSearchSpec("Deposit Id", sBatchId);
ExecuteQuery(ForwardOnly);
var HasRecord = FirstRecord();
while (HasRecord)
{
iClaimId = GetFieldValue("Claim Id");
with(oBCClaim)
{
InvokeMethod("SetAdminMode", "TRUE");
SetViewMode(AllView);
ActivateField("CMI Payment Variance Sum");
ActivateField("CMI Variance Tolerance Level");
ActivateField("Status Code");
54
ClearToQuery();
SetSearchSpec("Id", iClaimId);
ExecuteQuery(ForwardOnly);
if (FirstRecord())
{
sPayVariance = GetFieldValue("CMI Payment Variance Sum");
sVarToLevel = GetFieldValue("CMI Variance Tolerance Level");
if (ToNumber(sVarToLevel) < ToNumber(sPayVariance))
{
SetFieldValue("Status Code",
TheApplication().InvokeMethod("LookupValue","INS_CLAIM_STATUS","Payment Received"));
WriteRecord();
}
else if (ToNumber(sVarToLevel) >= ToNumber(sPayVariance) && ToNumber(sPayVariance) > 0)
{
with(oBCClaimPayment)
{
ActivateField("Payment Amount");
ActivateField("Payment Type Code");
ActivateField("Payment Status");
ActivateField("CMI Payment Credit Type");
NewRecord(1);
SetFieldValue("Payment Amount", sPayVariance);
SetFieldValue("Payment Type Code",
TheApplication().InvokeMethod("LookupValue","CMI_PAYMENT_TYPE","Variance"));
SetFieldValue("Payment Status",
TheApplication().InvokeMethod("LookupValue","FUNDRQ_STATUS","Verified"));
SetFieldValue("CMI Payment Credit Type",
TheApplication().InvokeMethod("LookupValue","CMI_PAY_CDT_TYPE","Consolidate"));
WriteRecord();
}
SetFieldValue("Status Code",
TheApplication().InvokeMethod("LookupValue","INS_CLAIM_STATUS","Closed"));
WriteRecord();
}
else if (ToNumber(sPayVariance) == 0)
{
SetFieldValue("Status Code",
TheApplication().InvokeMethod("LookupValue","INS_CLAIM_STATUS","Closed"));
WriteRecord();
}
}
}
WriteRecord();
HasRecord = NextRecord();
}
}
oBCBatch.InvokeMethod("RefreshBusComp");
}
}
55
function PaymentVarianceCheck()
{
try
{
var oBO = TheApplication().ActiveBusObject();
var oBC = oBO.GetBusComp("INS Claims");
var oBCPayment = oBO.GetBusComp("INS Claims Payments");
var iClaimTotal;
var iPayVariance;
var iVarToLevel;
var iPaymentType;
iPaymentType = oBCPayment.GetFieldValue("Payment Type Code");
with(oBC)
{
iPayVariance = GetFieldValue("CMI Payment Variance Sum");
iVarToLevel = GetFieldValue("CMI Variance Tolerance Level");
if (ToNumber(iPayVariance)!= 0)
{
if(iPaymentType=='Variance'){
SetFieldValue("Status Code",
TheApplication().InvokeMethod("LookupValue","INS_CLAIM_STATUS","Variance Created"));
}
WriteRecord();
}
else if (ToNumber(iPayVariance) == 0)
{
SetFieldValue("Status Code",
TheApplication().InvokeMethod("LookupValue","INS_CLAIM_STATUS","Closed"));
WriteRecord();
}
}
}
}
CMI CTI
function Service_PreInvokeMethod (MethodName, Inputs, Outputs)
{
try
{
if (MethodName == "Transfer")
{
//For transfer
var sActivityID; var boAction; var bcAction; var sFullName;
sActivityID = Inputs.GetProperty("ActivityID");
boAction = TheApplication().GetBusObject("Action");
bcAction = boAction.GetBusComp("Action");
with (bcAction)
{
//Query by Activity ID
SetViewMode(AllView);
56
ClearToQuery();
SetSearchSpec("Id", sActivityID);
ExecuteQuery(ForwardOnly);
if (FirstRecord())
{
//Update the CMI Owner FullName field
ActivateField("CMI Owner FullName");
sFullName = TheApplication().GetProfileAttr("Full Name");
SetFieldValue("CMI Owner FullName", sFullName);
WriteRecord();
Outputs.SetProperty("Result","1");
}
}
return(CancelOperation);
}
}// end of try
catch(e)
{
if(defined(e.errText))
{
TheApplication().RaiseErrorText("An exception occurred in the " +"ERROR: " + e.errText
+"STACK: " + e.toString());
}
else
{
TheApplication().RaiseErrorText("An exception occurred in the " + this.Name() + " object.
" + "ERROR: " + e.errText +"STACK: " + e.toString());
}
}
return (ContinueOperation);
}
CMI CATCH PROPERTYSET INTEGRATION
function Service_PreInvokeMethod (MethodName, Inputs, Outputs)
{ var psTemp;
try
{
if(MethodName == "StorePS")
{
{
psTemp = Inputs.Copy();
}
return (CancelOperation);
}
if(MethodName == "RecallPS")
{
Outputs.AddChild(psTemp.Copy());
return (CancelOperation);
}
if(MethodName == "ClearPS")
57
{
psTemp = null;
return (CancelOperation);
}
}
return (ContinueOperation);
}
CMI CALCULATE PRICE BS
function Service_PreInvokeMethod (MethodName, Inputs, Outputs)
{
try
{
if(MethodName == "CalculatePrice")
{
var sId = Inputs.GetProperty("RowId");
CalculatePrice(sId);
return(CancelOperation);
}
if(MethodName == "WholegoodsItemPrice") //added by Elen Yu
{
WholegoodsItemPrice(Inputs, Outputs);
return(CancelOperation);
}
if(MethodName == "OptionPricing")
{
OptionPricing(Inputs, Outputs);
return(CancelOperation);
}
return (ContinueOperation);
}
}
function CalculatePrice(sId)
{
try
{
var sBO = TheApplication().ActiveBusObject();
var sBC = sBO.GetBusComp("Quote");
var sItemBC = sBO.GetBusComp("Quote Item");
var isRecord; var isItemRecord; var sInputMargin="";
var sCost; var sProdType; var sDisAmt ;
var sRetainListPrice; var sListPrice; var sCostCalc;
var sSSAField; var sEBSPrice;
with(sBC)
{
SetViewMode(AllView);
ActivateField("CMI Input Margin");
ClearToQuery();
SetSearchSpec("Id", sId);
ExecuteQuery(ForwardOnly);
58
isRecord = FirstRecord();
if(isRecord)
{
sInputMargin = GetFieldValue("CMI Input Margin");
}
with(sItemBC)
{
SetViewMode(AllView);
ActivateField("Cost");
ActivateField("CMI Retain List Price Flag");
ActivateField("Unit Price");
ActivateField("Adjusted List Price");
ActivateField("CMI SSA Amount");//Added:JQ486
ActivateField("CMI EBS Net Price"); //Added on Mar03
ClearToQuery();
SetSearchSpec("Quote Id", sId);
ExecuteQuery(ForwardBackward);
isItemRecord = FirstRecord();
while(isItemRecord)
{
sProdType = GetFieldValue("Product Type");
sRetainListPrice = GetFieldValue("CMI Retain List Price Flag");
sCost = GetFieldValue("Cost");
sListPrice = GetFieldValue("Adjusted List Price");
sCostCalc = GetFieldValue("Write-In Product Flag");
sSSAField = GetFieldValue("CMI SSA Amount");
sEBSPrice = GetFieldValue("CMI EBS Net Price");
if(sRetainListPrice == "N" || sRetainListPrice == "" || sRetainListPrice == null)
{
sDisAmt = SetLIPrice(sInputMargin,sCost,sSSAField);
SetFieldValue("Unit Price",sDisAmt);
if(sCostCalc == "Y")
{
SetFieldValue("Cost",sCost);
}
WriteRecord();
}
else
{
/* SetFieldValue("Unit Price", sListPrice); */
SetFieldValue("Unit Price", sEBSPrice); //Added Mar03
if(sCostCalc == "Y")
{
SetFieldValue("Cost",sCost);
}
WriteRecord();
}
isItemRecord = NextRecord();
}//end of isItemRecord
}//end of Quote Item BC query
sBC.InvokeMethod("RefreshBusComp");
59
}//end of Quote BC query
return(CancelOperation);
}//end of try
}
function OptionPricing(Inputs, Outputs)
{
try
{
var sQuoteId = Inputs.GetProperty("Quote Id");
}
function SetLIPrice(sInputMargin,sCost,sSSAField)
{
try
{ var sMargin = ToNumber(sInputMargin);
var sItemCost = ToNumber(sCost);
var sSSA = ToNumber(sSSAField);
//JQ486: For Calculating ManualPriceOveride in case of SSA
if(sSSA == "" || sSSA == null)
{
sSSA = 0;
61
}
var sManualPriceOveride;
//building the formula --
//Manual Price Override : [(Cost for each product)/(1-(input margin percentage/100))]
var temp = sMargin/100;
var temp2 = 1 - temp;
//JQ486: Including SSA
sManualPriceOveride = (sItemCost - sSSA)/temp2;
}
return(sManualPriceOveride);
}
function WholegoodsItemPrice(Inputs, Outputs)
{
try
{
Outputs.SetProperty("Error Code", "0");
Outputs.SetProperty("Error Message", "");
63