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)

JavaScript not running in outlook client

(0) ShareShare
ReportReport
Posted on by

Hi all,

I have created a custom subgrid(in a HTML web resource) in the opportunity form which has a '+' button and the action behind the button is shown in the below function:

function openLookupWindow() {
var pid = parent.Xrm.Page.data.entity.getId();
var lookupurl = "/_controls/lookup/lookupinfo.aspx?" +
"AllowFilterOff=0&DefaultType=10011&DisableQuickFind=0&DisableViewPicker=0&IsInlineMultiLookup=0" +
"&LookupStyle=single&ShowNewButton=1&ShowPropButton=1&browse=false&objecttypes=10011";
var dialogwindow = new parent.Mscrm.CrmDialog(parent.Mscrm.CrmUri.create(lookupurl), window, 500, 500);
dialogwindow.setCallbackReference(function (result) {
for (var i = 0; i < result.items.length; i++) {
var oppress = new Object();
oppress.new_OpportunityId = { Id: pid, LogicalName: "opportunity" };
oppress.new_ResdexId = { Id: result.items[i].id, LogicalName: "new_resdex" };
var createdOppress = createRecordSync(oppress, "new_oppresSet");
refreshArea();
}
});
dialogwindow.show();
}

I am first opening the Lookup Record Window(Using the URL), getting the selected value in the window using dialogwindow.setCallbackReference() and creating the records.

The Script works perfectly fine with the Web Client but does'nt run in the Outlook Client. I guess the function setCallbackReference is not getting called.

Any ideas or any alternatives?

Please help!

Regards,

Kautuk

*This post is locked for comments

I have the same question (0)
  • Community Member Profile Picture
    on at
    RE: JavaScript not running in outlook client

    Hi Kiran,


    I had similar issue. We were using window.external.openWindow() method to open new IE windows from Outlook.
    However, this got broken after SP1 UR1 update for CRM Outlook client, with error "The given key was not present in the dictionary" which is typical C# error, and I don't even know what is the cause.  I am trying your workaround now.

    How do I get this 'Mscrm' object in Outlook? 
    Right now I get error 'Mscrm' is undefined when running this snippet you provided, and many others have also reported, as shown on this tickets


    https://community.dynamics.com/crm/f/117/t/180292

    https://community.dynamics.com/crm/f/117/p/139132/500699#500699



  • Community Member Profile Picture
    on at
    RE: JavaScript not running in outlook client

    Hi,

    I have the same problem with the same URL opening a dialog the same way.

    It works in Outlook client randomly, I think this lookup gets a worse performance on every click until it crashes

    Did you find an answer?

  • Community Member Profile Picture
    on at
    RE: JavaScript not running in outlook client

    Hey Kiran,

    Thank you for your reply. Your solution looks promising. I will definitely try it out.

  • Suggested answer
    Community Member Profile Picture
    on at
    RE: JavaScript not running in outlook client

    Follow the below code to fix this problem.

    check for the client type. If the client is outlook can use the below code which worked for me.

    if (Xrm.Page.context.client.getClient() == "Outlook")

    {

     var DialogOptions = new Xrm.DialogOptions();
            DialogOptions.width = 500;
            DialogOptions.height = 600;
            Xrm.Internal.openDialog(Mscrm.CrmUri.create(lookupurl).toString(), DialogOptions, null, null, function (res) {
              //Ur code goes here
            });

    }

  • Suggested answer
    Rajkumar Rajaraman Profile Picture
    on at
    RE: JavaScript not running in outlook client

    Hi Kautuk,

    Refer the following link:

    msdn.microsoft.com/.../gg328541.aspx

    Hope it helps.

    Regards,

    R.Rajkumar

    "Please mark my answer as verified if you found it helpful"

  • Community Member Profile Picture
    on at
    RE: JavaScript not running in outlook client

    Hi RajKumar,

    Thank you for your reply. Can you tell the location of the setCallbackReference method? I tried to add "ClientGlobalContext.js.aspx" as reference which did not help.

    Regards,

    Kautuk

  • Suggested answer
    Mithilesh Kumar Profile Picture
    10,047 on at
    RE: JavaScript not running in outlook client

    Hi Kautuk,

    The only solution to jscript code troubleshooting is Debugging.

    Add "debugger" to your code. Add it just after the function name, so that is it hit as soon as the function is called.

    This will ask you to choose the program using what you want to debug. Choose Visual Studio (hope you have one installed).

    Follow this tutorial for the same

    www.mayanksrivastava.com/.../debugging-java-script-in-visual-studio.html

    Hope that helps

    Thanks

  • Suggested answer
    Rajkumar Rajaraman Profile Picture
    on at
    RE: JavaScript not running in outlook client

    Hi Kautak,

    Have u forget to add reference to ClientGlobalContext.js.aspx?

    Please add and try it.

    Regards,

    R.Rajkumar

  • mscrmba Profile Picture
    on at
    RE: JavaScript not running in outlook client

    Does this help at all?

    crmentropy.blogspot.com.au/.../debugging-dynamics-crm-for-outlook.html

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…

Andrés Arias – Community Spotlight

We are honored to recognize Andrés Arias as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans