Alert() or Confirm() window when changing a content type in a Nintex Form


Badge +4

Hi,

Has anyone discovered a way to add an alert() or confirm() window to a Nintex form when a user tries to change the content type of the edit form using the 'change content type' control?

alternatively is there someway to force the user to save their changes on one content types form before changing content types?

Thanks!

Kimberley


10 replies

Userlevel 6
Badge +16

You could add a label alert on the Content Type screen

Badge +4

You mean adding it to the settings of the form when i modify the form per content type?

I have 6 content types in my list and the user may need to make updates on anyone of them.. I need to prompt them when they change the content type to save first..

Am I right Fernando Hunth that your suggestion is to have the prompt come up when they initially open the form?

Thanks!

Kimberley

Badge +9

Hi Kimberley,

If the user needs to update all content types, may I suggest to review them and put the common fields in a common Content Type, it will be less painful for them, or maybe it is too late or you have inherited of that design and I can understand.

Regards,

Christophe

Badge +4

Hi Christophe,

The user generally doesn't have to update more than one content type but there needs to be the flexibility to be able to update information across content types. I have added some fields to the default content type that i know someone will try to navigate through content types to update, but still with that potential i need to eliminate the possibility of user error and therefore users losing their data.

Hope that makes sense!

Thanks,

Kimberley

Badge +9

Hi Kimberley,

I am working with O365 and apparently I cannot add the Content Type Control to a Nintex Form.

Can you add a screen shot to make sure I understand it well.

Regards,

Christophe

Badge +9

Hi Kimberley,

I do not know if this can solve your problem but it works for a simple dialog list in O365.

Add this code to the Form Settings - Custom Javascript

NWF$(document).ready(function(){ 

var selectedContentType = NWF$('#' + ddlContentType + ' option:selected');  

NWF$("#"+ddlContentType).change(function()  

{     

  var strAnswer = confirm("Click OK if you you have already saved. Click Cancel if you need to save before switching to another content type."); 

if (strAnswer == false)

    {

     selectedContentType .attr("selected", true); 

    }

}); 

NWF$("#"+ddlContentType).click(function()   

{      

  selectedContentType = NWF$('#' + ddlContentType + ' option:selected');

}); 

});

where

ddlContentType is used in the Control Settings of the Content Type Control - Advanced Section

Store Client ID in JavaScript variable: Yes

Client ID JavaScript variable name: ddlContentType

Hope it helps

Christophe

Badge +4

Hey,

Just trying to test out your reply but getting a little stuck.

When I go to add ddlContentType as a Client ID in JavaScript i don't have any options under the advanced tab of my change content type control

182141_pastedImage_0.png

Badge +9

Hi Kimberley,

That is what I feared. Apparently you can not access that control with Javascript.

I cannot check more as the present time, I do not have acces to a SP on Prem.

But one idea from this post, is to create your own drop down box.

Regards,

Christophe

Badge +9

Hi Kimberley Morrison​,

Were you able to achieve your own drop down box?

Regards,

Christophe

Badge +9

Kimberley,

Here is the full explanation, hoping that you are able to Save the form and keep the item open in Edit mode to be able to switch to another content type.

Create a Calculated Value Control on your Nintex Form.

Select Display format: Drop down list

For Choices, be careful, format your entries like this, first the ID of the content type followed by | and then the name of the Content type. Separator is the ,

ex: 0x01001D88D253897DE34AB59916404D272CE9|Item,...

You can find the ID of the content type when you click on the New item at the end of the Url.

Remember to put ddlContentType

It is used in the Control Settings of the Content Type Control - Advanced Section

Store Client ID in JavaScript variable: Yes

Client ID JavaScript variable name: ddlContentType

Add this code to the Form Settings - Custom JavaScript

Do not forget to change the content of the variables strSite and strList:

NWF$(document).ready(function(){

var strSite = "https://yoursite/sites/yoururl";
var strList = "yourlistname";
var strUrl =  strSite + "/_layouts/15/start.aspx#/Lists/" + strList + "/EditForm.aspx?ID=1&Source="+ strSite +"/Lists/" + strList + "/AllItems.aspx&ContentTypeId=";
var selectedContentType = NWF$('#' + ddlContentType + ' option:selected');

NWF$("#"+ddlContentType).change(function()  

{     

  var strAnswer = confirm("Click OK if you you have already saved. Click Cancel if you need to save before switching to another content type."); 

if (strAnswer == false)

    {

     selectedContentType.attr("selected", true); 

    }
else
    {
     selectedContentType = NWF$('#' + ddlContentType + ' option:selected').val();
     window.top.location.replace = strUrl + selectedContentType;
    }

}); 

NWF$("#"+ddlContentType).click(function()   

{      

  selectedContentType = NWF$('#' + ddlContentType + ' option:selected');

}); 

});

Hope this helps,

Christophe Raucq

Reply