Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Issue on saving when cursor is on the text field

(0) ShareShare
ReportReport
Posted on by 355

Hi,

I have a piece of JavaScript as below which gets the data from text field when user save the record. I am calling the function through custom HTML button on the Form. My problem is when I enter the data and click outside of the field then if I click Save it is working fine but when I enter some data into the text field and without leaving the field if I click on the Save  record(custom button). It is not saving and getting NULL value. Could someone please suggest me how to do it. Many Thanks in Advance.

function createRecord() {
var oDescription = Xrm.Page.getAttribute("new_description").getValue();
if (oDescription != null) {
var callentity = {};
var activityId;
var currentUserId = Xrm.Page.context.getUserId();

var oLeadId = Xrm.Page.getAttribute("new_lead").getValue()[0].id;

callentity.Subject = "Call Activity";
callentity.Description = oDescription ;

XrmSvcToolkit.createRecord({....Some more functions here...

})
}


*This post is locked for comments

  • NEWGuy Profile Picture
    355 on at
    RE: Issue on saving when cursor is on the text field

    Hi David,

    Many Thanks. Still it's not working. Because if my cursor is on the Description field and when I click on the custom HTML Save Button nothing happening but when I come out of the field and try to save it then I can save. So is there any way to achieve it. I tried with IsDirty and Focus function but still no luck. Can you please suggest if you have any ideas. Thanks.

  • Community Member Profile Picture
    on at
    RE: Issue on saving when cursor is on the text field

    Hi Newguy,

    As you are calling the Javascript from a custom HTML page, it might be worth while prepending a window.parent to Xrm.Page.getAttribute as the script will be running on the custom html page, and not the CRM form itself, give that a try and let me know if that works.

    window.parent.Xrm.Page.getAttribute("new_description").getValue();

    there is an isdirty method,
    Xrm.Page.getAttribute(“new_description”).getIsDirty()
    its returns a bool

    regards,

      David Levins

  • NEWGuy Profile Picture
    355 on at
    RE: Issue on saving when cursor is on the text field

    Hi David,

    Thank you for your suggestion above but it is not working.

    I have a HTML button on the Form and a Text box where I enter some data after entering data without coming out of the textbox if I click on the Save button it is not saving and once if I click on the other field then after when I click on the button it is saving.

    So here I am trying to set the focus to some other field and which is not so elegant.Is there any other way to check the field is changed like ISDirty? Please suggest.

  • Community Member Profile Picture
    on at
    RE: Issue on saving when cursor is on the text field

    Hello NEWGuy,

    have you tried to remove focus from the textbox that was in focus?

    I'm going to presume the textbox you are referring to is 'new_description'

    so maybe try set the focus to another textbox in the first line of createRecord()

    e.g.

    var control = Xrm.Page.ui.controls.get(“new_lead”);

    control.setFocus();

    Regards,

      David Levins

  • NEWGuy Profile Picture
    355 on at
    RE: Issue on saving when cursor is on the text field

    Can Someone please suggest me on the above issue. Please....

    
                          

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

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,865 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,723 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156 Moderator

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans