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)

Unable to display custom ribbon button only on one form of an entity - Urgent

(0) ShareShare
ReportReport
Posted on by

Hi, 

I have been struggling with this for almost 2 weeks now and would love to get some help resolving this issue.

I have created a ribbon button on the opportunity entity in CRM 2013 and have used a custom enable rule to display the button only on one form from the two available(admin, sales).

I am able to see the button on web on the right form (admin), but it doesn't seem to be visible on Outlook client. I am using the following Javascript to enable/Disable the button and for some reason it looks like the JS is always returning false when called from Outlook.

I am using SetTimeout since outlook seems to be taking time getting the objects and throwing an error if that's not used.

Is there a better way to enable the button on one form and not the other?

function EnableRibbonButton()
{
	var client = Xrm.Page.context.client.getClient();
	if(client == "Web")
	{
		var form = Xrm.Page.ui.formSelector;
		if(form != null)
		{
			var formItem = form.getCurrentItem();
			if(formItem != null)
			{
				var formId = formItem.getId();
				if(formId == "ADMINFORMGUID")
				{
					return true;
				}
				else
				{
					return false;
				}
			}
		}
	}
	else if(client == "Outlook")
	{
		var form = getForms();
		var formItem = getFormItem(form);
		var formId = getFormID(formItem);
		if(formId == "ADMINFORMGUID")
		{
			return true;
		}
		else
		{
			return false;
		}
	}
}

function getForms()
{
	var form = Xrm.Page.ui.formSelector;
	if(form != null)
	{
		return form;
	}
	else
	{
		window.setTimeout("getForms()", 100);
	}
}

function getFormItem(form)
{
	var formItem = form.getCurrentItem();
	if(formItem != null)
	{
		return formItem;
	}
	else
	{
		window.setTimeout("getFormItem("+form+")", 100);
	}
}
function getFormID(formItem)
{
	var formId = formItem.getId();
	if(formId != null)
	{
		return formId;
	}
	else
	{
		window.setTimeout("getFormID("+formItem+")", 100);
	}
}


Any help would be greatly appreciated.

Thanks

Shaik

*This post is locked for comments

I have the same question (0)
  • Mamatha Swamy Profile Picture
    5,426 on at
  • Community Member Profile Picture
    on at

    Hi Mamatha,

    I have tried that but that doesn't seem to be working. Is there anything else I can try?

    Thanks

    Shaik

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