天翎MyApps技术社区 - 低代码平台 | 流程管理系统 | BPM软件

 找回密码
 注册成为天翎用户
查看: 2752|回复: 0

[函数] 创建新对象,把数据插入另外一张表里【函数-nsertDataOnOtherDoc】

[复制链接]
purple 发表于 2011-11-29 11:00:32 | 显示全部楼层 |阅读模式
本帖最后由 spiral 于 2013-3-1 13:48 编辑

函数格式:
InsertDataOnOtherDoc(formName,formId,fieldNames,fieldValues,parentDoc,isDateNames,isDateValues)
函数说明:
formName 表单名
formId 表单id
fieldNames 字段名,数组或字符串
fieldValues 字段值,数组或字符串
  parentDoc 父文档,可不传
isDateNames date类型的字段名(可不传)(string类型)
isDateValues date 类型的值 (可不传)(date类型)
示例:
实现InsertDataOnOtherDoc(formName, formId, fieldNames, fieldValues, parentDoc,isDateNames,isDateValues)函数的应用
  1. function InsertDataOnOtherDoc(formName, formId, fieldNames, fieldValues, parentDoc,isDateNames,isDateValues) {
  2.         var doc = getCurrentDocument();
  3.         var domain = getDomainid();
  4.         var application = getApplication();
  5.         var process = getDocProcess($WEB.getApplication());
  6.         var uuid = new Packages.cn.myapps.util.sequence.Sequence();
  7.         var child = new Packages.cn.myapps.core.dynaform.document.ejb.Document();
  8.         child.setId(uuid.getSequence());
  9.         if(parentDoc) child.setParent(parentDoc);
  10.         child.setFormname(formName);
  11.         child.setAuthor(getWebUser());
  12.         child.setFormid(formId);
  13.         child.setIstmp(false);
  14.         child.setApplicationid(application);
  15.         child.setLastmodifier(getWebUser().getId());
  16.         child.setDomainid(domain);
  17.         child.setMappingId(child.getId());
  18.         var count = 1;
  19.         var fieldName = "";
  20.         var fieldValue = "";
  21.         if (fieldNames.constructor == Array) {
  22.                 count = fieldNames.length;
  23.         } else {
  24.                 fieldName = fieldNames;
  25.         }
  26.         if (fieldValues.constructor != Array) {
  27.                 fieldValue = fieldValues;
  28.                 child.addStringItem(fieldName, fieldValue);
  29.         } else {
  30.                 for (var i = 0; i < count; i++) {
  31.                         child.addStringItem(fieldNames[i], fieldValues[i]);
  32.                 }
  33.         }
  34.         if(isDateNames && isDateValues){
  35.                 var datecount = 1;
  36.         var dateName = "";
  37.                 var dateValue = "";
  38.                 if (isDateNames.constructor == Array) {
  39.                         datecount = isDateNames.length;
  40.                 } else {
  41.                         dateName = isDateNames;
  42.                 }
  43.                 if (isDateValues.constructor != Array) {
  44.                         dateValue = isDateValues;
  45.                         child.addDateItem(dateName, dateValue);
  46.                 } else {
  47.                         for (var i = 0; i < datecount; i++) {
  48.                                 child.addDateItem(isDateNames[i], isDateValues[i]);
  49.                         }
  50.                 }
  51.         }
  52.         process.doCreate(child);
  53. }
复制代码
调用
  1. #include " autosqllib";
  2. InsertDataOnOtherDoc("formName","formId","fieldNames","fieldValues","parentDoc","isDateNames","isDateValues");
复制代码

本版积分规则

QQ|手机版|天翎MyApps技术社区 ( 粤ICP备11093750号 )

GMT+8, 2026-8-12 05:51

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表