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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Set Focus to Email Description field supported javascript

(0) ShareShare
ReportReport
Posted on by 315

HI ,

I have a JavaScript that modifies the subject on load of the email by adding opportunity number to it . But it sets the focus in Subject field . I want to have the focus set to description field but Description is inside a IFrame. We need a Supported java script to  set the focus on the field inside IFrame. We don't want to use JQuery as it is not recommended for form .

thanks

*This post is locked for comments

I have the same question (0)
  • Royal King Profile Picture
    27,686 on at

    Have you tried with

    Xrm.Page.getControl("description").setFocus();

  • kunalks2003 Profile Picture
    315 on at

    thanks for replying . i have tried that, does not work.

  • Suggested answer
    purwar purwar Profile Picture
    2,836 on at

    The code is fine.

    Please move the Xrm.Page.getControl("description").setFocus() in such a way that it executes as last statement of the form load script.

  • Mahendar Pal Profile Picture
    45,095 on at

    Hello,

    As your control is over iframe (assuming have html web resource ??) standard set focus won't work there, you can use JQuery to interact with your web resource, it is not recommended to use on entity form, but you could write code in your page which is in iframe to set focus when pages is loaded.

    Thanks

  • Suggested answer
    Hamzeh Zawahreh Profile Picture
    3,674 on at

    hi,

    try this :

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

    control.setFocus();

  • Suggested answer
    Hamzeh Zawahreh Profile Picture
    3,674 on at

    hi kunalks2003

    and also try this codes line sequentially:

    crmForm.all.some_other_field_on_the_same_tab.SetFocus();
    crmForm.all.yourReallyFieldName.SetFocus();

  • Aileen Gusni Profile Picture
    44,524 on at

    Kunals,

    So your description field is a textbox element inside the iframe which is the iframe is external app?

    There is no supported way from CRM SDK because this will access external app, if yes.

    Can check this as workaround

    alexking.org/.../iframe-element-focus

  • kunalks2003 Profile Picture
    315 on at

    hi Thanks for the reply.

    its the standard email form of CRM. If you look at the description i.e. the email body it is inside i frame .

  • Verified answer
    Royal King Profile Picture
    27,686 on at

    I got time to check this out myself and you are correct setting focus to description did not work. As description field is a rich textbox and there is no supported way to set focus to this control. Only way to set focus to this control is using unsupported javascript.

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…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans