Skip to main content

Restrict CRM 4.0 Form Fields via JavaScript

Recently had an issue where a series of calculated custom fields were inserted by a VAR, which would calculate the opportunity forecast value and another value for a forecast probability value.

Code was placed on the OnLoad(), to perform this action, but changes to this form would not save. So users could edit further percentages, but reports and views would not reflect the new value.

What I discovered, is that these fields were locked from saving data, as they were marked as read only. This was strange behavior, as new opportunities did not suffer from this, and the code that resided in the OnLoad() event was not coded to take account for only updates or create.

I came across this post: , dealing with CRM 3.0.

As a result, I customized the fields that were read only to normal. I then added this code to my OnLoad() event, to the Opportunity form, to disable the fields.

var CRM_FORM_TYPE_CREATE = 1;
var CRM_FORM_TYPE_UPDATE = 2;
//Adjust the display of the calculated fields to inline
//change field to enable
crmForm.all.CRMFIELD1.Disabled = true; //false
crmForm.all. CRMFIELD2.Disabled = true; //false

Then on each field that contains a variable to calculate these fields I added the following to the OnChange() event:

//change field to enable, so values can be saved
crmForm.all.CRMFIELD1.Disabled = false; //true

//Place your code below

//Disable Field after update
crmForm.all.CRMFIELD1.Disabled = true; //false


Then on the OnSave() event for the form, I then enabled the fields for saving.

Comments

Popular posts from this blog

SQl Upgrade Error - Access to the Path C:\Program Files\Microsoft SQL Server\110\License Terms\SQLServer2012_License_SQLBI_1033.rtf is denied

SQL Upgrade Error - Access to License Denied Ahh a wonderful time to experience an error, when you are upgrading SQL, during a limited window for downtime.  Sop much for the weekend plans eh? No worries, this one is easy.  In my case I received the following when downgrading an edition for a reporting Server that houses several instances.  After the first one processed, I received this error: If I browse to that path, we notice the file is set to read only. Easy enough, lets un-check read only and try again.  Success!  I had to do this for each instance install.  So if you have multiple instances be prepared to set the file to read/write each time.

SCSM Data Warehouse Cube / Dimensions do not process - Event 33573 / 35574

Recently I received an alert from our SQL server "OLE DB error: OLE DB or ODBC Error: Operation Cancelled HY008.   Around that same time, I found a few errors in our Operations Manager log on our SCSM 2012 R2 DataWarehouse Management Server.  Specifically Events 33573 and 33574. Event 33573 Warning Message : An Exception was encountered while trying during cube processing.  Message=  Processing warning encountered - Location: , Source: Microsoft SQL Server 2012 Analysis Services Code: 1092550657, Description: Errors in the OLAP storage engine: The attribute key cannot be found when processing: Table: 'WorkItemDim', Column: 'WorkItemDimKey', Value: '18553'. The attribute is 'WorkItemDimKey'..     Well, that appears that a overnight job did not run for our SCSM data warehouse.  However, when I looked at the Data Warehouse Jobs in the SCSM Console, all of the status were either set to Not Started, or success. Going back to the logs on the SCSM

PowerShell - Add telnet client to Windows Server 2012 R2

I was trying to check port specific communication on  a server, so I decided to power up good old telnet.  Much to my surprise it was not installed on the Server. PowerShell to fix that issue! Add-WindowsFeature telnet-client  All set.  No Reboot needed. -AJ