priority-web-sdk: fieldUpdate for choose field failed

十年热恋 提交于 2019-12-13 03:24:20

问题


My form contains a field with drop down values (the values came from the choose function) and when I am trying to update the field (with fieldUpdate) in the second time I always get the following error: "A record with the same value already exists in the screen", What is the correct order of actions that need to be done in order to achieve the right behaviour? This is my attempt to achieve that:

await actions.loginTest();
const form = await actions.priority.formStart(this.formName, 
this.onShowMessgeFunc, this.onUpdateFieldsFunc);
_formInstance = form;
const rows = await form.getRows(1);
console.log("parent form rows", rows);
await _formInstance.setActiveRow(1);
form.choose("CUSTNAME", '').then(options => {
let custOptions = options.SearchLine.map(x => {return {label:x.retval + " - 
" + x.string1, value: x.retval }});     
}).catch((err) => {
console.log("CHOOSE ERROR", err);
})    

When I select a value from the drop-down, those are my actions:

await _formInstance.fieldUpdate("CUSTNAME", data.value);
await _formInstance.saveRow(1);
const rows = await _formInstance.getRows(1);
console.log("rows", rows);

In the first time it work's great, but when I select a different value for the second time I get an error that say that this value already exists (it's like it think that I am trying to update the value but I don't, I just want to get the values of other fields that return as a result of the field trigger when I leave the field in Priority). I don't have any purpose to change values, just getting information on other fields and data from sub-forms.


回答1:


I don't have any purpose to change values, just getting information on other fields and data from sub-forms.

In order to achieve your purpose you could choose one of the following flows, that should work:

  1. Recommended: Use getRows() after you have setSearchFilter() in order to retrieve the row you're interested in including its fields. Then easily setActiveRow() with its index to startSubForm(). You could always use clearRows() to clear the current rows and retrieve others.

    Example:

    const form = await actions.priority.formStart(this.formName, 
                 this.onShowMessgeFunc, this.onUpdateFieldsFunc);
    const filter = {
      QueryValues:
      [{
        field: 'CUSTNAME',
       fromval: value,
       op: '='
     }]
    }
    await form.setSearchFilter(filter)
    const rows = await form.getRows(1);
    console.log("parent form rows", rows);
    await form.setActiveRow(1);
    await form.startSubForm(1);
    
  2. Perform the 'update' on a newRow() without calling getRows(). Then saveRow() and startSubForm() to get the information you need. Do this for each record you trying to retrieve its data.

    Explanation: When calling getRows() you retrieve some rows. Then you cannot update a key field with a value that already exists in the retrieved rows otherwise you get that error.



来源:https://stackoverflow.com/questions/52034074/priority-web-sdk-fieldupdate-for-choose-field-failed

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!