0

I have list in SharePoint Online. With type control people picker. How to delete the value that has been inputted, when approver 1 edit item to return empty. Thanks

enter image description here

2
  • How to clear value means ?? Just click on that close icon besides name and value will get cleared in the textbox. According to whatever I am observing in the image that field "Assign To" is a mandatory field so it cannot remain empty, if you try to save it as a blank field in your form. Dec 26, 2019 at 10:49
  • I am mean, I am have 3 approver. When approver 1 edit item, put Assign To with field mandatory. then Save Item. And to do Approved in approvals process. When approver 2 edit item on the same item, I am want Assign To previous erased automatic and there is no assign to the input by approver 1
    – Kfajar
    Dec 26, 2019 at 11:03

2 Answers 2

1

Tested script in my online environment, insert script editor webpart into the edit form and insert below script into it.

<script type="text/javascript" src="https://code.jquery.com/jquery-1.12.4.js"></script>
    <script type="text/javascript">
        SP.SOD.executeFunc('clientpeoplepicker.js', 'SPClientPeoplePicker', function () {
            window.setTimeout(function () {
                var controlName = 'Assigned To';
                // Get the people picker object from the page.
                var peoplePickerDiv = $("[id$='ClientPeoplePicker'][title='" + controlName + "']");
                //var peoplePickerEditor = peoplePickerDiv.find("[title='" + controlName + "']");
                var peoplePicker = SPClientPeoplePicker.SPClientPeoplePickerDict[peoplePickerDiv[0].id];
                if (peoplePicker) {
                    peoplePicker.DeleteProcessedUser();
                }
            }, 500);

        });        
    </script>
2
  • Thanks guy.. this is work for me!
    – Kfajar
    Dec 30, 2019 at 2:45
  • You could accept it as answer so it would help others.
    – Lee
    Dec 30, 2019 at 2:58
0

You can remove it using JS after loading "clienttemplates.js":

var peoplePicketEditor = $('[id^="' + fieldName + '"][id$="ClientPeoplePicker"]');
var spPeoplePicket = SPClientPeoplePicker.SPClientPeoplePickerDict[peoplePicketEditor[0].id];
spPeoplePicket.DeleteProcessedUser();

to delay execution use:

ExecuteOrDelayUntilScriptLoaded(youFunction, 'clienttemplates.js');
8
  • Hi, does this use tags <script> ?
    – Kfajar
    Dec 27, 2019 at 3:05
  • You can add JS using CSR. Dec 27, 2019 at 4:49
  • yes, i am add JS using CSr, but not working
    – Kfajar
    Dec 27, 2019 at 5:20
  • please review my code below: <script> $(document).ready(function() { var peoplePicketEditor = $('[id^="' + Assign To + '"][id$="ClientPeoplePicker"]'); var spPeoplePicket = SPClientPeoplePicker.SPClientPeoplePickerDict[peoplePicketEditor[0].id]; spPeoplePicket.DeleteProcessedUser(); }); </script>
    – Kfajar
    Dec 27, 2019 at 5:25
  • You code execute after page loading, you need to attach to change event: when approver change something. Isn't it? What error shows in console log? click F12 to show dev mode. Dec 27, 2019 at 5:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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