0

What I have is a list of documents that have different fields. I have a button called Submit - when this is clicked it changes the value of my dropdown from "Not in progress" to "Submit".

My flow triggers and its all working fine - except they need to refresh the page to see this working.

When I added in a simple jquery location refresh it just keeps refreshing the page non stop.

I've removed the refresh out of the code, how can I achieve this without breaking the page again :)

<script type="text/javascript"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script>
var targetListItem;
$(document).ready(function () {
    SP.SOD.executeFunc('sp.js', 'SP.ClientContext', execOperation);
});

function execOperation() {
    try {
        var  clientContext = new SP.ClientContext.get_current();      
        var myWeb = clientContext.get_web();
        var selectedItems  = SP.ListOperation.Selection.getSelectedItems(clientContext);
        var myList = myWeb.get_lists().getByTitle('Quality');
        var itemArray = [];
        for (var i = 0; i < selectedItems.length; i++) {            
             myListItem = myList.getItemById(selectedItems[i].id);

            myListItem.set_item('Submit','Submit');
            myListItem.update();
            itemArray[i] = myListItem;
             clientContext.load(itemArray[i]);
             clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded), Function.createDelegate(this, this.onQueryFailed));
        }   

            function onQuerySucceeded() {


location.reload();
}

function onQueryFailed(sender, args) {

alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());
}
    }
    catch (err) {
        alert(err);
    }
}


</script>

<input id="submitDocButton" type="button" value="Submit" onclick="execOperation();"></input>
2

It happens due to reload function so please replace

location.reload();

With

window.location = window.location.href;

And it will work fine.

More details please refer this stackoverflow link

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.