CRM7.1 sp2 - How to change a displayed value when the page loads (modify the html code) ?


Hello,
How can I change a value directly in the SolutionsDetailsBox when the page loads? I just want to change the displayed value of the field (I mean simply modify the html code of the page), not the real value of the field in the database.
I think it's in the Custom Content of the SolutionsDetailsBox. I tried the following script but that does not work.

<script>
window.attachEvent('onload', updaterating);
function updaterating()
{
CRM.AddContent('<' + 'script> document.getElementById("_Datasoln_yourrate").innerHTML = 12; <' + '/script>');
});
</script>

This script is for my tests. In fact I want to put the result of an SQL request but it is not the problem here.
For information: in the html it is named "_Datasoln_yourrate". In the database, the field is named "soln_yourrate" and it is an integer.

Extract of the html code of the page:

  • 0

    Hi,

    What I understood from your below post is you need to set the value in the Your Rate field on load of a screen. Well, you can achieve the same by writing client side script.

    window.attachEvent('onload', updaterating);

    function updaterating()

    {

    if(document.getElementById("_Datasoln_yourrate"))

    document.getElementById("_Datasoln_yourrate").innerText = 12;

    }

    Kindly note that value which you have set will be only for viewing purpose and it will not be updated in the Sage CRM database. As far as SQL request is concerned, you can write it in a Create Script section of any entity and then store it in a hidden variable. Finally you can get the value of SQL request on load of a screen.

    Hope this helps!

    Sincerely ,

    Dinesh

  • 0

    Thank you Dinesh this works!

    Now my problem is that instead of 12 I want to display the result of the following SQL request (the result of the request always changes depending on the user who is loading the screen):

    var query = CRM.CreateQueryObj("SELECT solrat_rate FROM solrating WHERE solrat_solutionid2 = '"+CRM.GetContextInfo('Solutions','soln_referenceid')+"' AND solrat_userid = '"+CurrentUser.user_userid+"'");

    At the begining I added a create script on the field soln_yourrate and put the result of the request in the value of the field (in the database). So it updated the database each time a different user loaded the page. I didn't need any client side script, but when the page loaded the value displayed was the second last value, not the last one added to the database.

    So how can I retrieve (client side) the result of my request without updating the database.

    Thanks in advance!