Display a button in ribbon when arriving to a step of a stage in a process flow in Dynamics CRM 2015 - dynamics-crm-2015

I need your help: How I can display a button in ribbon when arriving to a step of a stage in a process flow in Dynamics CRM 2015?
Thank you in advance !!

You can use the following code to get the Process stage:
Xrm.Page.getAttribute('stageid').getValue()
and the following code to get the ribbon button:
var btnRunWorklfow=top.document.getElementById("account|NoRelationship|Form|Mscrm.Form.account.RunWorkflow-Large");
To hide the button, you can use a javascript similar to this in one in one of the form or control events:
var stageID = Xrm.Page.getAttribute("stageid").getValue();
if (stageID == 'xxxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx') {
var btnRunWorklfow=top.document.getElementById("account|NoRelationship|Form|Mscrm.Form.account.RunWorkflow-Large");
btnRunWorklfow.style.display='none';
}
You can also use ribbon editor available in codeplex to disable your button based on your javascript.
refer: http://crmvisualribbonedit.codeplex.com/
This is also an useful link: Hiding/Showing a Section Based on the Current Stage

Related

Hiding account form Open Org Chart in Dynamics 365 unified interface

I'm using Ms Dynamics 365 online Version 9.1.00004626 for customer engagement.
On entity "account" form command bar in UCI, i have a button named Open Org chart this button doesn't appear in web classic interface. I need to hide it.
I tried with RibbonWorkBench, but i didn't see the button, i tried also xml customization file the button referenced by "ViewOrgChart", didn't appear.
How to hide this button?
Thanks for your help
Best Regards

Buttons in a view in Dynamics 365

I am new with Dynamics 365 and are not sure of how I can achieve this.
I am looking into having some buttons in a view.
Maybe a view isn't the best way of doing it, but what I want to do is to have a list of records connected to the logged in user (similar to a view)
But on each row/record I want to have multiple buttons. These buttons can be like 'Complete' (Changes status on task and updates the view) , 'Send email'(Starts a workflow) and so on.
What are some of the ways of doing this? Either with Javascript/C#/plugin or something else.
You cannot add buttons in views/subgrids directly.
That’s when we add ribbon/command bar buttons using Ribbon workbench usually.
Create a Workflow Short Cut Ribbon Button (No Code Solution!)
Update:
There is a PowerApps Components Framework (PCF - preview) coming out soon, then we can build custom grid control with the layout/buttons we want.
This can be achieved with RibbonWorkbench. My answer does not differ much with #arun vinoth answer but just added few explanation lines.
https://ribbonworkbench.uservoice.com/knowledgebase/articles/132235-create-a-workflow-short-cut-ribbon-button-no-code
If you look at view below where I have selected number of contact and then I have a Button at top "Nominieren" which is shown and clicking on it will perform whatever action is needed.
There will be java-script on click of button, from Java script you could call Action or workflow or perform operation in Java script itself.
Link for Adding new Button : https://community.dynamics.com/crm/b/crmtipsfromadeveloper/archive/2017/07/26/know-how-add-a-ribbon-button-using-ribbon-workbench
Now when you look at image below I have no contact selected and it does not show button on Ribbon.
It might be possible. I haven't tried this but you can write JavaScript for a view column now (since CRM 2016).
If you go to a view you can double click on a view column to view its properties. There are two properties you might be interested in:
Web Resource
Function
Here's a link to an MS page that explains how to use these options to add an icon. It might be possible to create a clickable button which uses CRM's WebApi to perform some actions: Docs # Microsoft

How to run two functions from one button in crm

I am using ribbon workbench and I need my customize button to activate two functions :
JS function
save function - that is already used in vanilla save button.
In ribbon workbench I connected my js function to my button - it works, to connect the Crm save function :
I inserted to Misc > Command core -> this func: Mscrm.SavePrimary
When I click my button the js function works but nothing is saved and I get a massage that my data is not saved, it seems that the crm function: Mscrm.SavePrimary, was fired but wasn't complete.
Is connecting these two functions to one button is possible?
If it's possible what is the right way?
The right way would be to use the Save function that is in SDK:
https://msdn.microsoft.com/pl-pl/library/gg334720.aspx#Anchor_8
Xrm.Page.data.entity.save() is equivalent of "Save" command that you have on command bar. What are you currently doing is not supported customization and is likely to stop working after any upgrade of the system
For people using Dynamics 365 Online version 9.x and later, save function is changed a little bit:
https://learn.microsoft.com/en-us/dynamics365/customer-engagement/developer/clientapi/reference/formcontext-data/save
formContext.data.save(saveOptions).then(successCallback, errorCallback);

Show/Hide CRM controls malfunctioning

I am setting the section properties of CRM form to have label & control in separate rows like below:
By default the form control will be visible=false. When I try the below snippets only label is showing up but not the textbox. If I use side by side setting, its working as expected.
Xrm.Page.getControl("myattribute").setVisible(true);
or
Xrm.Page.ui.controls.get('myattribute').setVisible(true);
Can I achieve this by some other supported means?
Update:
Ours is CRM 2015 on-premise. Not update 1.
I have tested the same behavior in Dynamics 365 CRM trial. Legacy form behaves the same way, but Turbo form is having the fix.
Can you please try the following options and check if the issue persists ?
1. Turn off legacy form rendering.
2. If you can use the Business Rules, to Show/Hide field and see if it works ?
3. You can use un-supported customization, to hide the textbox.
var curElement = document.getElementById(controlname + "_d");
if (curElement != null)
curElement.style.display = '';
This seems to be Product bug till date, even in latest version with legacy form.
For now as a workaround, we are keeping the controls in separate section to meet our need.
Am open to any other supported solution.

Hide/Unhide a ribbon button in Dynamics CRM 2015 by Javascript

I need your help: How I can Hide/Unhide a ribbon button in Dynamics CRM 2015 by Javascript?
Thank you in advance !!
You can achieve this by customizing Ribbon XML, using Ribbon Work Bench makes it easier than doing a manual edit. You would need to use the "Enable Rule" portion of the customization and call your JavaScript function, returning true/false would show/hide the button. If you simply need to hide it and not toggle the display, you could use the same tool to hide the button by simply selecting the button and hiding it using context menu options.

Resources