3

I'm looking to create a popup dialogue box when a column called 'Status' is set to 'Complete'. I want a popup box to ask "Confirm Complete?" with Yes or Cancel choices. Obviously Yes will update the record with Status Complete (which I have applied a filter already working to show the record in an "Archived" view, and again obviously, Cancel will cancel the changes.

Is this possible?

thanks...

  • I guess you want to do that in the edit form, am I right? – MdMazzotti Mar 5 '14 at 9:36
  • Yes, that's correct. I've set the list settings so that the edit form doesn't launch in a dialogue. – daryl Mar 5 '14 at 9:55
  • do you find a solution? In my way, it doesn't work in SharePoint 2013. – joern Oct 24 '18 at 5:19
2

You can hook into the PreSaveAction function and put your verification logic in here.

For example:

function PreSaveAction(){
  if($('select[title="Status"]').val() == "Completed"){
     var isConfirmed = confirm("Do you confirm task completion?");
     if (isConfirmed ) return true; //confirm changes
     $('input[name$="IOGoBack"]').click(); //cancel changes
  }
  return true;
}

For this you'll need jQuery. And as a side note, the selector based on title attribute can easily break in a multi-language site (because, if you change the display language, the title will change accordingly).

Update: I edited the function so that if the confirmation dialog returns false, the Cancel button click is triggered

| improve this answer | |
  • Thanks for that, however, is there perhaps something I'm missing, perhaps format-wise, as when I go to Edit HTML source, the above code actually shows as text instead of becoming background code. – daryl Mar 5 '14 at 10:06
  • The best thing would be to edit the page in SPDesigner and put the code inside a <script> tag at the bottom of the page. Or, you can add a CEWP to the page, from the web UI, and link to an existing js file that you'll have created and put inside a doc library of your choice – MdMazzotti Mar 5 '14 at 10:09
  • I'm unable to use SPDesigner, the company does not allow us to use this. I've entered the line [code]<script type="text/javascript">[/code] in and this now sets it as code, however, I'm receiving an error with details... Message: Object expected Line: 696 Char: 3 Code: 0 – daryl Mar 5 '14 at 10:11
  • OK, so the CEWP is your plan B – MdMazzotti Mar 5 '14 at 10:12
  • If you have got SP 2013, you can also use script editor webpart. – Nadeem Yousuf-AIS Mar 5 '14 at 10:21

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.