sql query in onchange script

Hello,

I have a custom entity and want to get a value (price) from a custom sql-table based on the chosen value of three fields (product, channel, place)

Every time one of the three fields were updated in the screen I need to update the price.

In the onchange scripts of these three fields I can not use server-side commands like "CRM.CreateQueryObj".

How can I solve my problem?

Thank you in advance!

Parents Reply
  • 0 in reply to Sage CRM

    Hello, 

    now I did it to request data from linked table.

    I have to use a view with union like this:

     Building Cross Database Views for Reporting 

    Now I have a problem to query my data.

    When I use this I got a result:

    var CrmExample = CrmExample || {};
    
    CrmExample.doit = function () {
    var compField = crm.fields("vpos_text1");
    var ID = 99;
    var art = 8;
    
    var successCompany = function(crmRecord)
    {
    document.EntryForm["vpos_text1"].value = crmRecord.preis_preis;
    }
    crm.sdata({
    entity: "vkagcrmpreisenew",
    id: ID,
    success: successCompany
    });}

    If I change the sdata parameter like this I get only "undefined".

    var CrmExample = CrmExample || {};
    
    CrmExample.doit = function () {
    var compField = crm.fields("vpos_text1");
    var ID = 99;
    var art = 8;
    
    var successCompany = function(crmRecord)
    {
    document.EntryForm["vpos_text1"].value = crmRecord.preis_preis;
    }
    crm.sdata({
    entity: "vkagcrmpreisenew",
    where: "preis_artnew eq "+art,
    success: successCompany
    });}

    The field "preis_artnew" is an integer.

    What is my fault here?

    Thank you!

Children