-->

App Maker Document approval template : How can I A

2020-02-07 04:49发布

问题:

I use document approval template, and I want to define default approver and stages.

I have tried to change the custom value associates to the userpicker widget in EditRequest Page to define a default Approver by changing the location from 'onValueChange' to 'onAttach'. I set default value for mail's approvers.

PageEditRequest/userPickerWidget

Function associates to the custom value of userPickerWidget

But I don't know how can I associate a new stage to an another approver...

I tried a lot of things who failed

Have you any ideas ?

I want to have this type of results without any client interaction :

Desired result

回答1:

The earlier answer points to solve the problem where user are adding stage manually. If you want all stages and all approvers list to be added automatically, follow the below steps.

  1. Open Edit Request page, in that page you can find event onAttach, this event will trigger when page is being loaded and data has not loaded yet. DMS Template has already provided a method called startLoading() to this Event.
  2. Locate startLoading() method in Client Script named EditRequestPage_Request. This method is calling loadEditRequestPage() method internally. Locate loadEditRequestPage() method.
  3. This method is adding a default stage (i.e. Stage 1) to the approval workflow. We need to perform our operations here for Automatically add approvers.
  4. Locate the line requestDs.relations.WorkflowStages.createItem in the code, this line is Adding a Stage to the workflow. So we need to add this line multiple times to Add multiple stages. In my below code I've show cased for 2 stages.

Code for adding 2 stages and 1 approver at each stage.

if (requestDs.item.WorkflowStages.length === 0) {

    requestDs.relations.WorkflowStages.createItem(function() {
    var createDatasource = requestDs.relations.WorkflowStages.relations.Approvers.modes.create;
    var draft = createDatasource.item;
    draft.Email = 'darpan.sanghavi@abc.com';
    draft.Name = 'Darpan Sanghavi';          


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

    });      

     requestDs.relations.WorkflowStages.createItem(function() {
    var createDatasource = requestDs.relations.WorkflowStages.relations.Approvers.modes.create;
    var draft = createDatasource.item;
    draft.Email = 'darpan.sanghavi@xyz.com';
    draft.Name = 'Darn Alarm';          


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

    }); 

}
  1. In the above code I've added lines inside requestDs.relations.WorkflowStages.createItem call, this call is creating a stage, inside a stage I've added Predefined Approver by Creating New Approver Data source.

This code still can be changed for incorporating changes like User's Thumbnail and some other changes, but this will help you get going. Add/Change code as per need.



回答2:

Answer to your question :

how can I associate a new stage to an another approver

Whenever you are clicking on + ADD STAGE button, you can add your predefined approvers in method createStage. You can do so by adding Approver in request.WorkflowStages.

Try doing this. If it does not work let me know. I will try to provide you some more code.



回答3:

The code from Darpan do add 2 stages and 1 approver at each stage automatically, however if you can see from the screenshot below, both Stage1 and Stage2 is under Current approval status. Which mean Stage2 approver can approve first before the Stage1 approver approve it yet. This is not correct is it?