Specific Attributes in Customized entity

Last post 11-18-2008 9:22 AM by Frank Hermes. 5 replies.
Page 1 of 1 (6 items)
Sort Posts: Previous Next
  • 10-05-2008 2:21 PM

    Specific Attributes in Customized entity

    Hi, I'd appeciate if you could help me with the following:

     

    1/Auto-numbering for custom entity?  Is is possible like for contract/case etc..

     

    2/If not, How to show to display the primarykey ID for entity instance?

     

    3/How to do basic calculated fields on a customized entity (Product Filed x Unit Price  without workflow or code triggered  client on change/on save event, or excel reporting?

     

    4/How/Where  to reduc e the size of data entry for customized attribute  with very few characters?

     

    5/How to embed the system new contact form into a customized entity main form (using iframe? If so what is the url to point to?)

     

    6/How to activate a picklist attribute (sub category) based on the choice of one item in another picklist attribute (main category)

     

    7/How to synchronize only part of Outlook contacts with CRM Contacts? (To avoid to have dentists and mother in laws in CRM database?)

     

     

     

     

     

  • 10-07-2008 6:18 AM In reply to

    Re: Specific Attributes in Customized entity

    Hi,

    Hope these answers help.  If you are looking for ways to accomplish these tasks without coding (based upon what you asked for item #3) it is probably not possible.

    1.  Your best option for creating an auto-numbering scheme like you suggest is to create this within a callout or plugin.  Option 2 would be to try and generate this client side with javascript using some kind of generated number on entity create.  You just need to come up with a method to ensure uniqueness.

    2.  You can't display the primary key field per se, but you could copy it to a field using javascript and reading it out of the crmFormSubmitId.  It won't be there until after the first save since it doesn't populate this field until after the

    3.  You can't do this without coding,  javascript can do this in the field onchange events for example.

    4.  Again, javascript.  CRM will also not allow the save of a record if the data exceeds the field length and would be truncated.

    5.  You could set your iframe to use something like http://<YourCRMPath>/sfa/conts/edit.aspx#

    6.  Javscript and a chained/linked picklist.  I've included some sample code for this at the bottom.

    7.  If you create the contact in Outlook, it will only get synced up with CRM if you select 'Track In CRM'. 

    Again, hope this helps. 

     Wes

    Chained Picklist Sample

    //Form on load event
    var CRM_FORM_TYPE_CREATE = 1;
    var CRM_FORM_TYPE_UPDATE = 2;

    // Only enable the dynamic picklist on a Create or Update form.  Disabled and
    // read-only forms are not editable and so do not require dynamic picklists.
    switch (crmForm.FormType)
    {
     case CRM_FORM_TYPE_CREATE:
     case CRM_FORM_TYPE_UPDATE:

      // Get a reference to the Sub-Industry picklist element for later use
      var oSubIndustry = crmForm.all.new_subindustry;

      // Cache the original picklist "Options" array in an "expando" on the
      // element.  We will use this original list to dynamicly re-build the picklist
      // based on the Industry the user selects.
      oSubIndustry.originalPicklistOptions = oSubIndustry.Options;

      // If there is not an Industry selected, we just need to disable the
      // Sub-Industry.  As soon as the user selects an Industry, we will
      // re-enable the Sub-Industry picklist.
      if (crmForm.all.new_industry.DataValue == null)
      {
       oSubIndustry.Disabled = true;
      }
      else
      {
       // There is a value already selected, we need to limit the available options
       // to what is valid for the currently selected Industry value.  The code to
       // do this already exists in the Industry Picklist's onchange event.  We will
       // re-use this code by manually firing the event.
       new_industry_onchange0();
      }

     break;
    }


    // Get the Industry Element, since this code is re-used by the form's onload event
    // we can not rely on the event.srcElement to have the approriate element.
    var oIndustry = crmForm.all.new_industry;

    // Initialize the Sub-Industry indexes
    var iStartIndex = -1;
    var iEndIndex = -1;

    // Depending on what the user selects in the Industry picklist, we will select
    // a range of options in the Sub-Industry picklist to display.
    //
    // For the purposes of this sample, it is assumed that the display text of each
    // Industry will be known and will not be localized.  We have also ordered the
    // options in the Sub-Industry picklist so that they are group sequentially per
    // Industry.  This allows the code to simply define start and stop Sub-Industry
    // indexes for each Industry.
    switch (oIndustry.SelectedText)
    {
     case "Accounting":
      iStartIndex = 1;
      iEndIndex = 5;
      break;

     case "Consulting":
      iStartIndex = 6;
      iEndIndex = 10;
      break;
    }

     

    //Picklist ONChange event
    // Get a reference to the Sub-Industry picklist element for later use
    var oSubIndustry = crmForm.all.new_subindustry;

    // If the indexes where set, update the Sub-Industry picklist
    if (iStartIndex > -1 && iEndIndex > -1)
    {
     // Create a new array, which will hold the new picklist options
     var oTempArray = new Array();

     // Initialize the index for the temp array
     var iIndex = 0;

     // Now loop through the original Sub-Industry options, pull out the
     // requested options a copy them into the temporary array.
     for (var i = iStartIndex; i <= iEndIndex; i++)
     {
      oTempArray[iIndex] = oSubIndustry.originalPicklistOptions[i];
      iIndex++;
     }

     // Reset the Sub-Industry picklist with the new options
     oSubIndustry.Options = oTempArray;

     // Enable the Sub-Industry picklist for the user
     oSubIndustry.Disabled = false;
    }
    else
    {
     // The user has selected an unsupported Industry or no Industry
     oSubIndustry.DataValue = null;
     oSubIndustry.Disabled = true;
    }

  • 11-13-2008 8:52 PM In reply to

    Re: Specific Attributes in Customized entity

    Regarding #1 Create AutoNumbers for any customizable entity in CRM 4.0 using our new product AutoNumbers

    Check it out at: http://www.crmInnovation.com/autonumber.asp

  • 11-14-2008 1:47 AM In reply to

    Re: Specific Attributes in Customized entity

    1. You can write your own autonumber function/callout/plugin easily. Just look here: http://blogs.msdn.com/crm/archive/2008/05/13/auto-numbers-in-microsoft-dynamics-crm.aspx. The blog article explains 3 options (option 1 is not transaction save!)

    2. in the onload event with crmForm.ObjectId

    3. as Wes said, this can't be done without coding (but it is very easy)

    4. in the attribute definitions in the entity customizations: change the max field length

    5. add an IFRAME to the form and a script like this in the onload event :

    //For exmaple to render activities in iFrame
    if (crmForm.FormType != 1)
    {
    var navActivities;
    navActivities = document.all.navActivities;
    if (navActivities != null)
    {
    navActivities.style.display = "none";
    document.all.IFRAME_Your_IFRAME_Name.src="areas.aspx?oId=" + crmForm.ObjectId +
    "&oType=2&security=852023&tabSet=areaActivities";
    }
    else
    {
    alert("Something went wrong");
    }
    }

    7. You can tell your Outlook which contacts to synchronize with an advanced find. (CRM -> Options -> Synchronization then click on "Local Data" in the second line and edit the data group

  • 11-18-2008 8:31 AM In reply to

    • Dodd
    • Not Ranked
    • Joined on 11-18-2008
    • Posts 2

    Re: Specific Attributes in Customized entity

    For Question #1: You would have to use JScript or a Plugin to Auto-Number custom entities. I have developed a simple solution in JScript that Auto-Numbers based on the Date and Time rather than increments, and it mimic the look of CRM Auto-Numbers. It would go in the Entity's OnLoad event and you would simply insert the schema name of the Auto-Number field:

    /************************************************
    * Create auto-number for Returns this will add
    * an auto-number to the Case's RA Number if the
    * Case Category = "Return"
    ************************************************/
     
    /* CRM Form Type must be "Update" */
    switch(crmForm.FormType) {
     case 2:
     /* Check to see if the Auto-Number field is NULL */
     /* TODO: REPLACE 'new_autonumberfield' WITH SCHEMA NAME OF YOUR ATTRIBUTE */
     if (crmForm.all.new_autonumberfield.DataValue == null) {
     /* Create Prefix section */
     /* TODO: REPLACE 'PRE' WITH YOUR OWN CUSTOM ENTITY PREFIX */
     var strPrefix = "PRE-";
     /* Create Date section */
     var myDate = new Date();
     dtDate1 = myDate.getDate();
     strDate1 = dtDate1.toString();
     dtDate2 = myDate.getMonth() + 1;
     strDate2 = dtDate2.toString();
     strDate = strDate1.concat(strDate2);
     /* Create String section */
     var randomLetters = '';
     /* Loop for 4 random letters */
     for (var i = 0; i < 4; i++) {
     /* fromCharCode formula assigns an alpha value to the random Integer */
     randomLetters = randomLetters + String.fromCharCode(65 + Math.round(Math.random() * 25));
     }
     strName = "-" + randomLetters;
     /* Create Integer section */
     var iNum = Math.random();
     iNum = iNum.toString();
     iNum = iNum.substr(8, 4);
     /* Concatenate Prefix, Date, String, and Integer sections */
     concatNumber = strPrefix.concat(strDate, strName, iNum);
     /* Write value to RA Number field */
     crmForm.all.new_autonumberfield.DataValue = concatNumber;
     /* Auto-Number is Read-Only, so force value to CRM DB */
     crmForm.all.new_autonumberfield.ForceSubmit = true
     }
     break;

     case 1:
     case 3:
     case 4:
     case 5:
     case 6:
        /* DO NOTHING */
        break;
    }

  • 11-18-2008 9:22 AM In reply to

    Re: Re: Specific Attributes in Customized entity

    I would not recommend placing the auto-number function in the form onload event. This will not work if the record is created/updated via a workflow or the webservice or bulk edit! This should be done in the plugin.

Page 1 of 1 (6 items)