donderdag 5 februari 2009

Blog moved

New address: http://kennyvaes.wordpress.com

vrijdag 19 september 2008

Refreshing a parent window when crmForm.IsDirty

When you try to refresh the parent window from an ISV page and the crmForm was
modified but not saved, you will get a confirmation dialog from CRM asking you
to continue or cancel the action.

To disable this behaviour you can Save the CRM form before the refresh action.

This seems to be standard CRM behaviour. You can try this when modifying an
account and then deactivating it. The new values will be saved automatically and
the account will be deactivated.

Put the following code in the OnInit of the aspx page:

protected override void OnInit(EventArgs e)
{
// Check if the crmForm was modified.
Response.Write("<script>" + "\n");
Response.Write("if (window.dialogArguments.document.crmForm.IsDirty == true)" + "\n");
Response.Write("{" + "\n");

Response.Write(" window.dialogArguments.crmForm.Save();" + "\n");
Response.Write("}" + "\n");
Response.Write("</script>;");

base.OnInit(e);
}

Regards,

Kenny

woensdag 20 augustus 2008

Hidden buttons reappear when resizing a crmForm

In a previous post I described how to hide custom buttons in a toolbar.
When a CRM form is resized by the user it appear that these hidden buttons will show up again.

To avoid this behaviour you should put your code into a global function and attach this function to the resize event of the window.

Example:

This code should be placed in the onload of the form.

HideButton = function()
{
var ULListItems = document.getElementById("mnuBar1").rows[0].cells[0].getElementsByTagName("UL")[0].getElementsByTagName("LI");
for(var i=0; i -1)
{
ULListItems[i].style.display = "none";
}
}
}

// Execute the function when loading the form
HideButton();

// Execute the function when the form is resized.
window.onresize = HideButton;

maandag 30 juni 2008

Read-Only fields don't get saved in the database.

When changing the value of a read-only field with JavaScript the new value will not be saved into the database.

To save the newvalue set the ForceSubmit property of the field to true.

crmForm.all.new_customfield.ForceSubmit = true;

Not the new value will also be saved into the database.

woensdag 25 juni 2008

Navision Application Server does not start: The Breakpoints already exists.

Sometimes a NAS tends to hang when there are breakpoints present in the database.

The following message will be displayed in the event viewer:

The Breakpoints already exists.

Identification fields and values:
Object ID='50001',Object Type='Form',Trigger Line='4',Code No='7'

To avoid this message you can simply delete all the breakpoints in NAV before running the NAS.

You can do this in either the object that is run by the specific NAS or in the NASHandler trigger of codeunit 1.

Simply add a line like "recBreakpoint.DELETEALL" where recBreakpoint points to a Record variable of the virtual Breakpoint table.

vrijdag 13 juni 2008

SELECTSTR limitations in NAV

There is a function in NAV that enables you to retrieve a string at a certain position in a comma seperated string.

There are a few limitations to this functions.
  1. You are foreced to use a comma ','
  2. You cannot use the same string twice in the same comma seperated string



From the NAV help file:
Comments
SELECTSTR treats string values as OPTIONS. This
means that identical values in different strings are not allowed.


A simple solution can be found on mibuso. Using this function removed both limitations as you can specifiy which seperation value to use.



fctGetFieldContent(pFieldNo : Integer;pText : Text[1024]) : Text[1024]
// ******************************************************************* //
// Code From Mibuso: //
// http://www.mibuso.com/forum/viewtopic.php?t=1429&highlight=strset //
// ******************************************************************* //

ReturnString := '';
FieldsFound := 1;
boo := -1;
REPEAT
CounterPos += 1;
IF pText[CounterPos] = '"' THEN
boo *= -1
ELSE BEGIN
IF (pText[CounterPos] = ',') AND (boo = -1) THEN
FieldsFound += 1
ELSE
IF FieldsFound = pFieldNo THEN
ReturnString := ReturnString + COPYSTR(pText,CounterPos,1);
END;
UNTIL (CounterPos = STRLEN(pText)) OR (FieldsFound > pFieldNo);

EXIT(ReturnString);



NOTE: You could also pass the seperation string to the function and replace the line IF (pText[CounterPos] = ',') AND (boo = -1) THEN with IF (pText[CounterPos] = pSerperator) AND (boo = -1) THEN

All credits go to PrebenRasmussen who posted this on Mibuso.

donderdag 12 juni 2008

Hiding custom buttons in CRM 4.0 Toolbar

In CRM 3 it was possible to hide a button on a toolbar just by calling the document.getElementById("").style.display = "none" method.

This will NOT work in CRM 4.0. The ID of the button seems to be generated when the CRM Form is loaded. One time it might be ISV_New_1_MyButtonID the other time it might be ISV_New_39_MyButtonID.

A simple workarround is by checking all the LI items in the UL of the MenuBar and by comparing its ID with "MyButtonID".
To do so use the following javascript in the forms OnLoad event:



var ULListItems = document.getElementById("mnuBar1").rows[0].cells[0].getElementsByTagName("UL")[0].getElementsByTagName("LI");
for(var i=0; i -1)
{
ULListItems[i].style.display = "none";
}
}