0

This info is very useful in order to pre-set the staging approval and it works. But the thing is the stage loaded to slow and the loading bar is close even before all the stage finish loading. I believe it has to be with the app.closeDialog(). So I try to put it inside some condition to check if the Label1 has finish loaded or not:

requestDs.relations.WorkflowStages.createItem(function() {
var createDatasource = requestDs.relations.WorkflowStages.relations.Approvers.modes.create;
var draft = createDatasource.item;
draft.Email = 'xxx@airasia.com';
draft.Name = 'xxxx xxxx';          

createDatasource.createItem(function(createdRecord) { }); 

  if (requestDetailsPage.descendants.StagesList.descendants.StagesListRow.descendants.DraftStagePanel.descendants.Grid1.children.Grid1Cell.descendants.Label1.loaded) {
   app.closeDialog();    
   }     
 });
}

So if Label1 had finished loading only then it will close the loading bar. Anyway I don't think I have reference it correctly to the Label1 and got error like

descendent is not defined

Can anyone help me to solve this? or suggest a better to way to do it ..

alep
  • 135
  • 12
  • I think your problem occurs once you reference a list with rows, since your StagesList.descendants can have multiple rows and then your grid can have multiple cells. Therefore it would appear that you are in fact referencing many Label1 widgets and your client might have issues with that. Rather than basing this on if Label1 is loaded it would be much more efficient to base this on the datasource that is bound to Label1, if you have a binding on Label1. – Markus Malessa Jan 07 '19 at 14:47
  • so how do I check if the last item of the Grid has been loaded or how do I point it to the last datasource item of the grid? – alep Jan 08 '19 at 04:01
  • Lets say your datasource for the grid is MyDatasource1. Then you would simply do if(app.datasources.MyDatasource1.loaded) { //your function if true }. However, if you already loaded that datasource due to some other process, then this would not work. The better way to do this would be to reload the datasource in your process and then call this script: app.datasources.MyDatasource1.load(function() { app.closeDialog(); }); this would then close your dialog after successfully loading your datasource. – Markus Malessa Jan 08 '19 at 14:15
  • ahh I think the second one you said will works tq – alep Jan 09 '19 at 02:58

0 Answers0