Accessing field values from another entity via an advanced search select

Hi,

I've been tasked by my manager to see if it is possible to pull information from a quote into an opportunity.

At the moment within our test system, I managed to get an advanced search select to look at the quotes that were created from a opportunity, I've been trying for a while to pull certain values from the selected quote to populate opportunity fields, the reason behind this is to have our users have a quick "summary" of a quote that will most likely to convert into an order.

I'm familiar with accessing information across entities with CRM.GetContextInfo("entity","field name") but only when it's been a 1:many relationship for example, quotes getting information from the opportunity as in our CRM one opportunity can have many quotes but not the other way round.

We're hoping this can be done, I've tried different ways of approaching it but no luck,

Any help on this would be amazing,

Thanks in advance,

Lee

  • 0

    The answer to the question depends on when you want to pull the values across.

    If you want to edit the opportunity, select the quote, then click Save and have, for example, the quote total to set the opportunity forecast value then you can do this via a table script.

    If you want to edit the opportunity, select the quote, then have the fields updated whilst still in edit mode, you can use the client side api to make an sdata server side call to get the quote data and then set the on screen values without the need for a post back.

  • 0

    Hi Daniel,

    Thank you for replying to my post.

    I think the best method for us would be using the client side api to get the data, I've tried using CRM.GetContextInfo but no luck with it, if you have any suggestions on the script that would be needed, that would be fantastic!

    It's amazing to see what can be achieved with customising CRM, I'm constantly learn new little tricks to get the system to work as our users like to use it.

    Thanks once again Daniel,

    Lee

  • 0

    The link just shows how the crm.sdata() method works. This is an Ajax call.

    You can add an onchange script to the Advanced Search Select that executes an Ajax call, using crm.sdata(). The function that runs on successful completion of the fetch can then update the other fields.

  • 0

    Hi Jeff,

    Thank you very much for the link, with the link am I able to populate opportunity fields with an 'selected' quote from the advanced search select?

    I'm looking forward to hear from you, I've used a good amount of your post and suggestions for fixes already.

    Thank you

    Lee

  • 0

    Hi everyone,

    Using the link from Jeff, I've tried writing up script and no luck, this is what I came up with

    crm.ready(function()

    {

    var quoteField = crm.fields("oppo_primequote");

    var quoteID = quoteField.value();

    var successQuote = function(crmRecord)

    {

    crm.fields("oppo_quotevalue").value = quoteField.quot_quotevalue;

    }

    crm.sdata

    ({

    entity: "Quotes",

    id: quoteID,

    success: successQuote

    });

    })

    Any help on getting this right would be amazing :)

    Thanks in advance

    Lee

  • 0

    Where have you put the script? In the custom content on onchange for the oppo_primequote field.

    The issue is 'probably' this line:

    crm.fields("oppo_quotevalue").value = quoteField.quot_quotevalue;

    which should be something like:

    crm.fields("oppo_quotevalue").value(crmRecord.quot_quotevalue);

    Just on that, its worth knowing that best practice is to use a prefix to the field to denote its custom, for example oppo_c_primequote. This means that if Sage ever added new functionality that used a new field call oppo_primequote it wouldn't break your existing code. It also helps to understand whats custom and what not in the future.

  • 0

    Hi Daniel,

    I'll try the change to see if that works, thank you on the advice with the field names, I'm currently testing this in our test crm so most of the fields are custom.

    I add my company initials and my name into the field name to know who created the field.

    Thanks once again Daniel

    Lee