I'm enumerating forms / subforms like so:
var pdqFormLoad = function(form) {
if (form) {
var
i,
col,
subf
;
console.log("Opened form [%s].", form.title);
console.log("\nColumns of $s.", form.title);
for (i in form.columns) {
col = form.columns[i];
console.log(" -- %j", col);
};
console.log("\nSubforms of %s.", form.title);
for (subf in form.subForms) {
console.log(
" -- Opening subform %s.",
subf
);
pdq.startForm(form, subf, pdqFormLoad);
};
}
else {
console.log("No form.");
};
};
Firstly I note that only the title attribute is provided. Unfortunately the "formName" parameter of the startSubForm function requires the internal form name, rather than the title descriptor.
/* Debug output */
Connectiong to https://www.eshbelsaas.com/ui/.
Opening form [ORDERS] in company [usdemo].
Opened form [Sales Orders].
Subforms of Sales Orders.
--Opening subform
{"title":"Attachments"}.
So I wasn't expecting the subsequent call to startSubForm to work:
pdq.subForm = function (FormName, pdqFormLoad) {
console.log("Opening subform [%s] in company [%s].", FormName, _config.company);
eventEmitter.on('pdqFormLoad', pdqFormLoad);
priority.startSubForm(FormName, pdq.ErrorCallback, pdq.onUpdateFields).then(
function (form) {
eventEmitter.emit('pdqFormLoad', form);
},
function () {
eventEmitter.emit('pdqFormLoad', null);
}
);
}
What I wasn't expecting was for the package to deny all knowledge of the function:
Opening subform [Attachments] in company [usdemo].
(node:38560) UnhandledPromiseRejectionWarning:
Unhandled promise rejection (rejection id: 1):
TypeError: priority.startSubForm is not a function
Any suggestions please @NeomiBushary, @Leor?
pdq.startForm = function (parent, FormName, pdqFormLoad) {
eventEmitter.on('pdqFormLoad', pdqFormLoad);
if (parent) {
console.log("Parent form.\n%j", parent);
parent.startSubForm(FormName, pdq.ErrorCallback, pdq.onUpdateFields).then(
function (subform) {
console.log("Sub form.\n%j", subform);
eventEmitter.emit('pdqFormLoad', subform);
},
function () {
eventEmitter.emit('pdqFormLoad', null);
}
);
} else {
priority.formStart(
FormName,
pdq.ErrorCallback,
pdq.onUpdateFields,
_config.company,
0
).then(
function (form) {
eventEmitter.emit('pdqFormLoad', form);
},
function () {
eventEmitter.emit('pdqFormLoad', null);
}
);
};
}
This works for the call to formStart (parent==null). But when I call the startSubForm on the parent form (created by the formstart call), the resulting form object passed to the [onSuccsess] event is the parent form, not the requested sub-form.
An example...
parent.startSubForm("EXTFILES" ...
where parent is a form object created by formStart with parent.name = "ORDERS"
...then(
function (subform) {
subform.name is also = "ORDERS"
Any ideas please?
Here's the parent / returned sub-form objects.
Parent form.
{
"name": "ORDERS",
"title": "Sales Orders",
"subForms": {
"EXTFILES": { "title": "Attachments" },
...
},
"activations": {
...
},
"columns": {
...
},
"oneline": 0,
"isquery": 0,
"ishtml": 0
}
Sub form.
{
"name": "ORDERS",
"title": "Sales Orders",
"subForms": {
"EXTFILES": { "title": "Attachments" },
...
},
"activations": {
...
},
"columns": {
...
},
"oneline": 0,
"isquery": 0,
"ishtml": 0
}
Another example of a call to startSubForm
returning the parent form, rather than the requested subform...
function thisapp(){
return new Promise((resolve, reject) => {
formStart('APPGEN', showMessage, updateFields).then(
function (appgen) {
var thisQuery = QueryValue();
thisQuery.field="APPNAME";
thisQuery.fromval=config.appname;
var f = FilterValue();
f.QueryValues.push(thisQuery);
appgen.Filter = f;
appgen.getRows(0).then(
function(rows) {
appgen.setActiveRow(1);
resolve(appgen);
},
function(message){
reject(message)
}
)
},
function(message){
reject(message)
}
)
});
};
function appForms(appgen, formName){
return new Promise((resolve, reject) => {
appgen.startSubForm("APPFORMS", showMessage, updateFields).then(
function (appforms) {
var thisQuery = QueryValue();
thisQuery.field="FATENAME";
thisQuery.fromval=formName;
var f = FilterValue();
f.QueryValues.push(thisQuery);
appforms.Filter = f;
resolve(appforms);
},
function(message){
reject(message)
}
)
});
};
function priorityReady() {
login(config).then(
function(){
thisapp().then(
function(appgen){
appForms(appgen, "DOCUMENTS_Q").then(
function(appforms){
appforms.getRows(0).then(
function(rows) {
console.log(rows);
}, showMessage
)
}, showMessage
)
}, showMessage
)
}, showMessage
)
}
答案 0 :(得分:0)
我将逐一回答这两个问题:
首先,打开的subForms
对象上存在的form
属性是一个javascript对象,其中键是内部子表单名称,值是带有子表单标题的对象。
for (subformName in form.subForms) {
console.log("--Opening subform: " + subformName);
}
将输出:
Subforms of Sales Orders.
--Opening subform EXTFILES
为了检索包含子表单所有属性的form
对象,您必须使用startSubForm
启动子表单。
其次,startSubForm
函数是form
检索的父formStart
对象的实例方法。它不是优先级模块的全局方法。
所以你应该这样做:
formStart('ORDERS',...)
.then(function(form) {//retrieve the parent form object
form.startSubForm('EXTFILES') //start a subform for that form
.then(function(subform) { ...}
});
startSubForm
为特定表单启动子表单,这就是为什么应该在其父表单的特定form
对象上调用它。要启动子子表单,应在startSubForm
对象等上调用subform
。
通常我会提到为特定表单执行操作的所有方法都是form
对象的实例方法。可用实例方法的列表记录在here