Dynamic CRM 2011. Hide/show tabs using radio buttons issue - dynamics-crm-2011

I have this code that hides tabs and shows tabs in CRM 2011. By default all tabs are hidden, but when the client has the product purchased (yes selected), the tab is showen.
The issue I am having is when I click yes and save & close. Then reopen the account, the tab is hidden, but the option is still yes.
The code is:
function showTab(tabNumber, optionField, optionValue) {
if (Xrm.Page.getAttribute(optionField).getValue() == optionValue) {
Xrm.Page.ui.tabs.get(tabNumber).setVisible(true);
}
else {
Xrm.Page.ui.tabs.get(tabNumber).setVisible(false);
}
}
The option I have is:
2,"new_server",'1'
I got the code from this place:
Show a Tab Dynamics CRM 2011
I am still working on this.

You need to register this function on both the form's OnLoad event and the field's OnChange event. It sounds, from your description, that it is registered and working for the OnChange event but the OnLoad event.

You currently have the function registered on the onChange event for the radio button control.
Additionally, you need to register an onLoad event for the form.
Create a new web resource.
Open Form Properties.
Add form to available resources.
Add event handler onLoad, and call your webresource.
In the web resource you can just have a call to your showTab function.

When you open the form for customization, look at the top ribbon of the form. You will see Form Properties icon right next to Preview. Click on Form Properties and then add the JavaScript web resource in the Form Library.
Choose Event: OnLoad from the drop down and then click add under the Event Handler.
Choose the web resource of your choice, add the function name being used in your code (showTab).
This will add the function to your Onload event of the form.

Related

xpages extension library dialog update data table

I have a xpages page that has a data table in a panel that calls an extension library dialog whose function is to create documents that are displayed in that data table. I would like to know if there is any way to by pressing the button to close the dialog refresh the data table with the new documents created.
I've used what's mentioned here to achieve that in the past:
XPages:dialog box refreshing a panel on close
Use a parameter in the .hide method to specify a control to refresh when closing the dialog. https://www-10.lotus.com/ldd/ddwiki.nsf/xpDocViewer.xsp?lookupName=Domino+Designer+XPages+Extension+Library#action=openDocument&res_title=Modal_dialogs_ddxl853&content=pdcontent
I was able to close the dialog box and update the data table as follows:
In the onClick event on the client side, and I put the code:
Dijit.byId ("# {id: dialogboxname}"). Hide ("panelWithDataTable")
And in the onComplete event of the button I use the code below:
Var idPanel = '# {id: panelWithDataTable}';
XSP.partialRefreshGet (idPanel)

Foundation 6 off-canvas disable close if user click on a link

How and where I need to set the data-close-on-click params in my off-canvas to avoid the menu to close when user click on a link inside the menu?
Using jquery:
$('#yourDatePickerID').click(function(e)
e.stopPropagation();
e.preventDefault();
});
Depending on which date picker you are using this may or may not work. It may even not allow you to open the calendar image. If it doesn't work I suggest you look into what event for your date picker is fired when the ok button is clicked. Attach this code to that event instead of the click event and try again.

How can I add a bit of custom functionality to every CRM 2011 grid ribbon?

I have a small bit of custom functionality which I need to run from each and every grid ribbon in CRM 2011. The functionality is in a JS web-resource and I can attach it to a button enable rule and it all works fine.
The issue is that I need this to run on every grid in CRM, but I'm struggling to find something in the ribbon which appears on every screen. I did try attaching it to one of the buttons in the Jewel menu, but this only fires if the user clicks on the "File" tab.
Any thoughts...?
The jewel menu button is a good idea.
Add an anonymous JavaScript function to the library you are adding to the jewel button.
This will run when the library is loaded, just after the page loads:
var whatever = 30; // maybe you do not need a parameter
(function (what) {
/* Do what you need to do */
}(whatever));
If it’s on premise I‘d inject my script to the ribbon.js or global.js or some other js and ping from there.
Another option, less intrusive , is to use a resource that runs in each and every form i.e. myframewrok.js. This resource can check for the opener and inject the script to the opener dynamically.
A third options might be to ping a web service using a plug-in registered on execute or retrieve multiple messages which fire repeatedly for any grid in the system.
In the end we attached it to the "Advanced Find" button as this appeared on every ribbon that we needed the functionality on. The Jewel menu did not seem to work for us as it only fired when the user actually clicked the "File" button.

How to capture the save ribbon event for custom web part?

I have two webparts on a Project Details Page, webpart #1 is a default form webpart, webpart#2 is a custom webpart with custom form.
Now when I click on "Save" in ribbon it fires the save event for Web Part 1.
My question: Is there a way to capture the save ribbon event, so I can trigger the save event of my custom web part ?
Thank you,
We can specify the OnSaveHandler at runtime as follows,
SPContext.Current.FormContext.OnSaveHandler = btnSave_Click;
You can try to achieve this using javascript. You need to add your custom script block with function PreSaveAction.
Something like this:
<script>
function PreSaveAction(){
//Do your stuff
}
<script>
Please refer to this post.

CRM 2011 Sub-Grid: Call JavaScript On-Click or On-Focus

How can JavaScript execute when a sub-grid receives focus?
I have a sub-grid that shows all Cases associated with an Account.
I would like to disable some fields on the form when the sub-grid receives focus.
RibbonDiffXML action for a ribbon button:
<Actions>
<JavaScriptFunction Library="$webresource:mda_convertemailtocaselib" FunctionName="ConvertEmailToCaseLib.addToCase">
<CrmParameter Value="SelectedControlSelectedItemIds" />
</JavaScriptFunction>
</Actions>
This passes the sub-grid select items to a ribbon button, but I would like the JavaScript to execute before the ribbon button is pressed.
I haven't tried either of these out, but hopefully one of them should work for you.
Although it is a subgrid, there still is a control on the form. Unfortunately there is no "supported" way to know when a control gets focus since there aren't any OnFocus/OnBlur methods exposed via the CRM JS API. However you should be able to add your own JS event handler for that control and disabled the fields via the API Xrm.Page.getControl("fieldname").setDisabled(true)
I'm not 100% sure if this way would work, but it would be pretty sweet. Create a CustomRule EnableRule. In this CustomRule you call your own JS. In this create a function where you disable the fields and then return true to make the button enabled. It would look something like this:
function disableFieldsEnableRule() {
Xrm.Page.getControl().setDisabled(true);
...
...
return true; // so the button is enabled
}
The only reason I'm not sure if this will work is because I'm not sure if the Enable rules are checked each time you click on the subgrid or just the first time (I think it should be every time). Also I'm not sure if you want those fields re-enabled once you click off. If you do you might have to do something similar to this with a button on the native form, or something else.

Resources