locked
CRM 4.0 and Coding RRS feed

  • Question

  •  

    I was wondering if some of the unsupported javascript Properties still work in 4.0 in particular the SetFieldReqLevel and Disabled properties. I've got some examples from 3.0 that worked, but not so much in 4.0.

     

    What I'm ultimately trying to accomplish is to set up dynamic requirement settings for a field based off of another field (picklist or lookup), and also how to hide fields on a form unless either another field reads a certain value, or someone with 'x' name or 'x' security role is editing the form. I'm not horribly great at writing the script just manipulating things and piecing things together so any help is wonderful and most appreciated.

    Thursday, October 23, 2008 9:28 PM

Answers

  • Hi Sleahy,

     

    To hide a field: crmForm.all.fieldname.style.display=="none";

    To make a field visible: crmForm.all.fieldname.style.display=="block";

     

    To mange with dynamic picklists. Look these codes,

    var oField = crmForm.all.SOME_PICKLIST_FIELD_ID;

    // Determine how many items there are in the picklist
    alert(oField.Options.length);

    // Set the value to 1
    oField.DataValue = 1;

    // Show the the text for option #1
    alert(oField.SelectedText);

    // Delete the first option by value
    oField.DeleteOption(0);

    // Add an option to the picklist, note that the CRM Platform must be aware of this information
    oField.AddOption("Test", 0);

     

    Also if you need related picklists,you can also do that, Refer the Crmsdk4.0.5.

    CrmSDK4.0.5\sdk\client\fullsample\dynamicpicklist\

     If Crmsdk4.0.5 is not with you.You can download it from,

    http://www.microsoft.com/DOWNLOADS/details.aspx?familyid=82E632A7-FAF9-41E0-8EC1-A2662AAE9DFB&displaylang=en

    its the 4.0.7 version.

     

     

     

    Friday, October 24, 2008 4:58 AM

All replies

  • Hi Sleahy,

     

    To hide a field: crmForm.all.fieldname.style.display=="none";

    To make a field visible: crmForm.all.fieldname.style.display=="block";

     

    To mange with dynamic picklists. Look these codes,

    var oField = crmForm.all.SOME_PICKLIST_FIELD_ID;

    // Determine how many items there are in the picklist
    alert(oField.Options.length);

    // Set the value to 1
    oField.DataValue = 1;

    // Show the the text for option #1
    alert(oField.SelectedText);

    // Delete the first option by value
    oField.DeleteOption(0);

    // Add an option to the picklist, note that the CRM Platform must be aware of this information
    oField.AddOption("Test", 0);

     

    Also if you need related picklists,you can also do that, Refer the Crmsdk4.0.5.

    CrmSDK4.0.5\sdk\client\fullsample\dynamicpicklist\

     If Crmsdk4.0.5 is not with you.You can download it from,

    http://www.microsoft.com/DOWNLOADS/details.aspx?familyid=82E632A7-FAF9-41E0-8EC1-A2662AAE9DFB&displaylang=en

    its the 4.0.7 version.

     

     

     

    Friday, October 24, 2008 4:58 AM
  • Here is a post on how to check the current user's security role using JavaScript. You can put the code in the onLoad event of your form:

     

    http://jianwang.blogspot.com/2008/01/crm-40-check-current-users-security.html

     

    Friday, October 24, 2008 6:09 AM
  • Most of the unsupported client functions still work in CRM 4.0 - the main one that doesn't is the RemoteCommand web service supports a lot less than it used to in CRM 3.0.

     

    The following post summarises the changes - http://mscrmuk.blogspot.com/2007/11/changes-to-client-side-code-for-crm-40.html - it was written when CRM 4.0 was still in Beta, but I think it's still accurate

     

    Friday, October 24, 2008 8:29 AM
    Moderator
  •  

    Thanks everyone for the examples and great resources. I just wasn't sure about some of the language that needed to be used with the .display etc. I appreciate the help.

     

    It seems that when i go to hide a field with the style.displayed="none" code it works fine for picklists and nvchar fields, but when I try it for a lookup field it only takes away the magnify glass leaving the field to be filled in with either the Form assistant or auto resolution. Is there a way to get the whole field hidden?

    Friday, October 24, 2008 2:19 PM