web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Facing difficulty with the work of "save" button

(0) ShareShare
ReportReport
Posted on by

There are two field in the account form named "gst no" & "pin code". we have added a java script code where it will check that "gst no" & "pin code" is already exists or not in the accounts database if it already exists then the field value will be blank against on change event,this code is running successfully,so after the on change event code running successfully the value of those field remains blank but when we click the "save" button it is getting saved.But we want to restrict the "save " button here only. Our requirement is if the "gst no" & "pin code" value remains blank then the form will not be saved. i'm attaching the code which i have written against "on save" button.

function fnTest(econtext)

{

var Cat1 = Xrm.Page.getAttribute("new_gstno").getValue();

var Cat2 = Xrm.Page.getAttribute("address1_postalcode").getValue();

if(Cat1==null && Cat2==null)

{

if(econtext != null && econtext.getEventArgs() != null)

{

alert("Please Provide a different GST Number and Pin code");

var eventArgs = econtext.getEventArgs();

if(eventArgs.getSaveMode() == 1 || eventArgs.getSaveMode() == 2 || eventArgs.getSaveMode() == 70)

{

eventArgs.preventDefault();

            }

         }

     }

}

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    RaviKashyap Profile Picture
    55,410 Moderator on at
    RE: Facing difficulty with the work of "save" button

    Hi,

    It looks like that you need to make the 2 fields mandatory. You don't need to write a javascript for this, simply make these field business required and the error message will appear automatically on save.

    If you don't want to make field mandatory then you can create a business rule and make the field mandatory.

    Hope this helps.

  • Suggested answer
    Dynamics365 Rocker Profile Picture
    7,755 on at
    RE: Facing difficulty with the work of "save" button

    Make both fields mandatory. There is no need of Java Script.

    If there is business restriction to make these fields mandatory then use Business rules.

  • Community Member Profile Picture
    on at
    RE: Facing difficulty with the work of "save" button

    i know this sir,already one code is running on change to prevent the duplicate entry and if duplicate entry will be there then that two particular field value will be blank.I want that java script which will prevent to save the details when that two particular field will be blank.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
HR-09070029-0 Profile Picture

HR-09070029-0 2

#1
UllrSki Profile Picture

UllrSki 2

#3
ED-30091530-0 Profile Picture

ED-30091530-0 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans