Skip to main content

Search

Button actions delay

Comments

2 comments

  • AndrewBerezovskyy2

    Hello Manuel Habert

     

    For this 

    • The problem is, that I need to authenticate on a popup. During this authentication the other two actions (Save and Redirect) already start.
      Is there a possibility to wait until my custom code is finished?

    you can use next approach:

     

    In you code you will add next line: (window.O365GroupCreated = true)

    function createOffice365Group(token) {
       jQuery.ajax({
            type: "POST",
            url: "https://graph.microsoft.com/v1.0/groups",
            headers: {
                "Authorization": "Bearer " + token,
                "Content-Type": "application/json"
            },
            data: group,
            dataType:"json"
            }).done(function (response) {
    window.O365GroupCreated = true;
                console.log("Successfully created group.");
            }).fail(function () {
                console.log("Creating group failed.");
            });
    }

     

    Then you must delete redirect action and add form load action which will continuously check whether group was created and if it was created than redirect to your url . Code will looks like:

    var redirectUrl = ... // can be formed using placeholders

    //check each 1 sec
    function checkWhetherO365GroupExist(){
        // do whatever you like here
         if(window.O365GroupCreated){
              window.loacation.href = redirectUrl ;
         }
        setTimeout(checkWhetherO365GroupExist, 1000);
         // Also you can stop checking using some timeout
    }
    checkWhetherO365GroupExist();

     

    Regarding

    • Is it possible to edit the current SharePoint item with the result of REST call?

    Yes. For example you can add button with action. Than you must add action with  type execute code where you will perform your REST call. You REST call will return some value and then you can programatically update listitem . How to do this you can find here  https://msdn.microsoft.com/ru-ru/library/office/hh185011(v=office.14).aspx

     

    Kind Regards
    Andriy Berezovsky

    0
  • ManuelH

    Hi Andrew Berezovskyy

     

    Thanks for your reply.

    Both could solve my problems. I deleted the save and redirect actions and I'm doing everything in my JavaScript.

     

    Best Regards

    Manuel Habert

    0

Please sign in to leave a comment.