cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

How can I get the form mode (New, Edit, Display) using jquery (NFW$)?

Jump to solution

Hi,

 

I'm trying to use the custom javascript section to run a few bits of different code depending on the form mode but have been unable to work out how I can get the code to recognise whether the form is in New, Edit or Display mode.

 

Has anyone been able to do this or able to offer a suggestion?

 

Any help appreciated.

 

Stuart

Labels: (2)
Tags (1)
Reply
16 Replies
Not applicable

Re: How can I get the form mode (New, Edit, Display) using jquery (NFW$)?

Jump to solution

One of the way maybe checking the url, something like this:

var isNewMode = document.location.pathname.indexOf("/NewForm.aspx") > -1;
var isDisplayMode = document.location.pathname.indexOf("/DispForm.aspx") > -1;
var isEditMode = document.location.pathname.indexOf("/EditForm.aspx") > -1;

if(isNewMode)
{
     alert("New");
}

if(isDisplayMode)
{
     alert("Display");
}

if( isEditMode)
{
     alert("Edit");
}

Reply
Not applicable

Re: How can I get the form mode (New, Edit, Display) using jquery (NFW$)?

Jump to solution

Thanks for the suggestion. Would this also work when the form is embedded as a web part in a page?

0 Kudos
Reply
Not applicable

Re: How can I get the form mode (New, Edit, Display) using jquery (NFW$)?

Jump to solution

Sorry that just saw your replied, I afraid it not work if form is embedded as web part as it basically depends on URL displayed in your browser

0 Kudos
Reply
cju
Nintex Newbie

Re: How can I get the form mode (New, Edit, Display) using jquery (NFW$)?

Jump to solution

I reply maybe a bit late but another suggestion (that will work in a form embedded in a web part) would be to :

  • add a calculated value control in the form with the following formula :

        If(Is Display Mode,"display",If(Is Edit Mode,"edit","new"))

  • Store the client id of this control in a javascript variable (in the Advanced panel of the control settings)
  • Set the recalculate formula settings to Yes for every form mode
  • In javascript, hide the control via it's client id on the form load event
  • In javascript, you will then be able to get the control's value to know if the form is in edit, display or new mode
Reply
Not applicable

Re: How can I get the form mode (New, Edit, Display) using jquery (NFW$)?

Jump to solution

Hello,

Is there any way to get an url which can use both create mode and edit mode action ?. Instead of :

- one link for create mode

- one link for edit mode

0 Kudos
Reply
cju
Nintex Newbie

Re: How can I get the form mode (New, Edit, Display) using jquery (NFW$)?

Jump to solution

I don't think that it exists

Reply
Not applicable

Re: How can I get the form mode (New, Edit, Display) using jquery (NFW$)?

Jump to solution

Ok, thank you for answering me

0 Kudos
Reply
leif_frederikse
Nintex Newbie

Re: How can I get the form mode (New, Edit, Display) using jquery (NFW$)?

Jump to solution

Hi Stuart,

You could simply use the "Common" functions IsEditMode, IsDisplayMode and IsNewMode in your Javascript:

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

    if ({Common:IsNewMode}) {

Regards

Leif

Reply
cju
Nintex Newbie

Re: How can I get the form mode (New, Edit, Display) using jquery (NFW$)?

Jump to solution

That's awesome !

Thanks for sharing !

0 Kudos
Reply