locked
Adding custom html in an entity form, but not inside an iframe RRS feed

  • Question

  • I want to display a custom rich message with some graphics to the user when he saves an entity, For example, when the user creates an account.

    I can suscribe to the save form event and execute an script, show and hide elements, no problem. But I didn't find a way to embed some custom html (something inside a div) in the form. What I can do is insert a web resource, but in this case the resource is inserted inside an iframe, what is a limitant for my purposes.

    I just want some custom html in the form. Is there a way to do this?



    Thanks in advance.

    Friday, March 7, 2014 3:45 PM

All replies

  • Hi Marcos,

    You might want to look at setting Form level notifications.

    Xrm.Page.ui.setFormNotification(message, level, uniqueId);

    Hope this helps!

    Thanks,

    Swaroop

    Friday, March 7, 2014 7:10 PM
  • If your CRM system is 2011 and you can't use setFormNotification, you can still achieve your goal by showing/hiding the iFrame in the script and call a function in an HTML Web Resource and pass the parameter (message to be shown and graphic info, etc.).

    Monday, March 10, 2014 7:05 AM
  •  IN case you want to add Custom |HTML following example will help, suppose you wanna create custom button on form then create a multilinetext field add it to form and remember that field schemaname

     Now open form properties. 

     Create a javascript resource file with following code. new_validationbutton is your field name. ctrl.innerHTML=btn is actually replacing  ctrl.innerHTML with button HTML code.

    Check following example code....

    function contactsOnLoad(){ 
          convertWebResourceToButton('new_validatebutton', 'Build Condition', '150px', '3px');
        }
         
        function convertWebResourceToButton(fldName, btnLabel, btnWidth, leftMargin){ 
           var btn = '<button id="btn_' + fldName + '" ' + 
                               ' style="margin-width:' + btnWidth + ';" ' + 
                               ' class="ms-crm-Button" ' + 
                               ' onmouseover="Mscrm.ButtonUtils.hoverOn(this);" ' + 
                              ' onmouseout="Mscrm.ButtonUtils.hoverOff(this);" ' + 
                            '>' + btnLabel + '</button>'; 
          
          var ctrl = Xrm.Page.ui.controls.get(fldName)._control.get_element().childNodes[0];
        
          // Replace controlewith buttom 
          ctrl.innerHTML = btn; 
         
          // Add Event to the newly created button 
          ctrl.firstChild.attachEvent('onclick', ShowModal);
    return false;
        
       }


    Thanks Regards Prashanth Kamasamudram Even the least work done for others awakens the power within; even thinking the least good of others gradually instills into the heart the strength of a lion.


    Monday, March 10, 2014 11:28 AM