Wednesday, 17 August 2016

Insert Label After the Field in CRM Form using Javascript

Hi all,
Long time I did not blog any post due to workload.
And this is my first post in this month (I know it is end of the month already)
This post basically a quick one because I have the requirement.

So, the users just want to have guidance when they entering inputs in the system.

Which we can have these solutions:

1. Tooltip (using CRM Field description)

See my post here:
http://missdynamicscrm.blogspot.sg/2014/05/crm-20112013-power-of-description.html

2. Using HTML Web Resource

This is a supported way and very useful as well. But it will make the form slower because will load the web resource and how many web resource you should create and insert. Well, you can create 1 common .html then pass the label text as the parameter

3. Using other way

So, unfortunately if those 2 solutions still not the best choice, we could go to another way using the help of CSS and Javascript.

*This is unsupported way…

And here is the Code

The Code


function insertLabelToField(fieldname, text, objSpan) {
    var elemDiv = document.getElementById(fieldname + "_c");
    //var tbl = document.createElement('table');     //elemDiv.parentNode.insertBefore(tbl, elemDiv.nextSibling);
    //var tr = tbl.insertRow();     //var td1 = tr.insertCell();     //td1.appendChild(elemDiv);     var td1 = elemDiv;     //td1.style.borderRight = "2px solid #c1c7c4";     td1.style.paddingBottom = "5.5px";
    var spanPref = null;
    if (!objSpan) {         spanPref = document.createElement('span');                 //you can change the color condition here         if (attr(fieldname).getRequiredLevel() == "required") {             spanPref.style.color = '#e31a1a';         }         else {             spanPref.style.color = '#4b4c54';         }         spanPref.style.fontSize = '10.51px';         spanPref.style.fontStyle = 'italic';     }     else {         spanPref = objSpan;     }     spanPref.id = 'spanPref_' + fieldname;         td1.appendChild(spanPref);     document.getElementById('spanPref_' + fieldname).innerText = text; }

How to Call

 
insertLabelToField(“fieldname”, "(Please describe me)");


And here is the Result

image

Hope this helps.

Thanks

18 comments:

  1. Hi,
    Glad I found your site, this is an eye-opener for marketers. We are proud to be a solution provider for a diversified customer database, ranging from the small, medium technology firms to the giant multinationals. Generate more revenue with email marketing, b2b marketing, list solutions & market research services. Microsoft Dynamics CRM Users Email List

    ReplyDelete
  2. These ways are very simple and very much useful, as a beginner level these helped me a lot thanks fore sharing these kinds of useful and knowledgeable information.
    AWS Training in Chennai

    ReplyDelete


  3. شركة نقل عفش من الرياض الى الامارات
    من اهم الشركات التى تقوم باعمال النقل على اعلى مستوى من خلال توفير عدد من الخدمات الاساسية المميزه التى تساعد فى الوصول الى افضل النتائج فى الحفاظ على الاثاث ضد اى تغيرات يتعرض اليها الاثاث فاذا اراد ان تقوم باعمال شركة شحن عفش من الرياض الى الاردن الى اى مكان
    شركة نقل عفش بالرياض عمالة فلبينية

    ReplyDelete
  4. Thanks a lot for sharing us about this update. Hope you will not get tired on making posts as informative as this. 
    Online DevOps Certification Course - Gangboard
    Best Devops Training institute in Chennai

    ReplyDelete
  5. It's interesting that many of the bloggers to helped clarify a few things for me as well as giving.Most of ideas can be nice content.The people to give them a good shake to get your point and across the command
    best rpa training in bangalore
    rpa training in pune | rpa course in bangalore
    RPA training in bangalore
    rpa training in chennai

    ReplyDelete
  6. Thanks for posting this info. I just want to let you know that I just check out your site and I find it very interesting and informative. I can't wait to read lots of your posts
    python Course in Pune
    python Course institute in Chennai
    python Training institute in Bangalore

    ReplyDelete
  7. I have visited this blog first time and i got a lot of informative data from here which is quiet helpful for me indeed. 
    python Course in Pune
    python Course institute in Chennai
    python Training institute in Bangalore

    ReplyDelete
  8. Alot of blogs I see these days don't really provide anything that I'm interested in, but I'm most definitely interested in this one. Just thought that I would post and let you know. Nice! thank you so much! Thank you for sharing.
    Website Development company in Delhi
    Website Designing Company in Delhi

    ReplyDelete
  9. Can I simply say what a relief to uncover somebody who really knows what they are discussing on the internet.
    You actually understand how to bring an issue to light and make it important.
    More people have to read this and understand this side of your story.
    It’s surprising you’re not more popular given that you surely possess the gift. If anyone is looking for weight loss medicines at cheaper price you can immediately call on +1-661-2217635 and get the best prescription by the experts.
    Buy Reductil 15MG
    Buy Meridia 15MG
    Buy adipex 37.5mg
    Buy Ambien 10mg
    Buy Klonopin 1mg
    Buy Valium 5mg
    Pain Relief Medicines Online
    Reduce Fat now with pills
    Erectile dysfunction solution is here
    Best anxiety medicine

    ReplyDelete
  10. Attend The Python Training in Hyderabad From ExcelR. Practical Python Training Sessions With Assured Placement Support From Experienced Faculty. ExcelR Offers The Python Training in Hyderabad.
    python training in bangalore

    ReplyDelete

My Name is..