1.在Applet子类型Control上新建记录(Name,HTML Type,Method Invoke);
2.从控件列表中选择定义的按钮控件将其拖动到界面;
3.在Applet子视图Applet User Prop新建记录,Name格式为:[CanInvokeMethod: Submit](注意:冒号后面又一个英文空格),Value为TRUE;
4.在Applet视图选择添加按钮的Applet[KIVI Order Form Applet],右键选择Edit Server Scripts,选择使用eScipt,在WebApplet-WebApplet_PreInvokeMethod中编写代码
function WebApplet_PreInvokeMethod (MethodName)
{
if(MethodName == "Submit")
{
var bcOrder = this.BusComp();
with(bcOrder)
{
this.BusComp().ActivateField("Order Number");
if(FirstSelected())
{
var orderId = GetFiledValue("Order Number");//获取当前记录的订单ID
var psIn = TheApplication().NewPropertySet();
var psOut = TheApplication().NewPropertySet();
psIn.SetProperty("OrderId",orderId);
var bsOrder = TheApplication().GetService("KIVI Order Service");
bsOrder.InvokeMethod("Submit",psIn,psOut);//调用刷新界面的BS
psIn.Reset();
psOut.Reset();
psIn.SetProperty("Refresh All","Y");
// TheApplication().GetService("FINS Teller UI Navigation").InvokeMethod();
}
}
return (CancelOperation);
}
return (ContinueOperation);
}
5.在Business Service视图新建记录-SNTO Order Service,设置属性External Use为Y
6.在Business Service子视图Business Service Method新建记录
7.在Business Service Method子视图Business Service Method Arg新建记录
8.在Business Service视图选择新建的SNTO Order Service 右键选择Edit Server Script,在Service-Service_PreInvokeMethod中编写代码
function Service_PreInvokeMethod (MethodName,Inputs,Outputs)
{
if(MethodName == "Submit")
{
var orderId=Inputs.GetProperty("OrderId");//BS中定义的Submit方法所定义的输入参数
SubmitStatus(orderId);
return (CancelOperation);
}
return (ContinueOperation);
}
9.在general declarations申明一个新的方法[SubmitStatus(orderId)]
function SubmitStatus(orderId)
{
var BO_KIVI_Order = TheApplication().GetBusObject("KIVI Order");
var BC_KIVI_Order = BO_KIVI_Order.GetBusComp("KIVI Order");
var sSubmit = TheApplication().InvokeMethod("LookupValue","KIVI_ORDER_STATUS","Submitted");//
with(BC_KIVI_Order)
{
ActivateField("Order Status");
SetViewMode(AllView);
ClearToQuery();
SetSearchExpr("[Order Number]='"+orderId+"'");
ExcuteQuery(ForwardOnly);
if(FirstRecord())
{
SetFieldValue("Order Status",sSubmit);
WriteRecord();
}
}
BO_KIVI_Order = null;
BC_KIVI_Order = null;
}
10.编译运行