SData, Selection and user selection fields.


Want to ask a question about SData, Selection and user selection fields.

A customer has a requirement to automatically fill some fields when creating a new opportunity with the same information in the previous opportunity for the same company they are creating the current opportunity.

My first thought was to do it with a SData query which gets data from the previous opportunity once the company has been set in the current opportunity.But 

But SData is retuning translations for selection fields (like oppo_source)  and Name+Lastname for user selection fields (like oppo_assigneduserid) which make the returned values unusable to assign it to the current record.

In the other hand, for text only or integer fields it works perfectly (I use “virtual” fields of these types to work around this).

Can someone  confirm-me this is the expected behaviour for SData on CRM 2020R2 and earlier or I’m missing something Frowning2?

PS: I find this old post that seems to confirm me that is an old know issue:  Sdata pulling through names rather than IDs, despite the Sdata Schema showing that the type is xs:integer - Sage CRM General Discussion - Sage CRM - Sage City Community

Thanks in advance

  • Why can't you just do it with Create Scripts?  For each field that you want to fill in put in a little script that picks out the value from the old opportunity and then inserts it as the default value of the new field.  That is so much easier than messing around with client side sdata scripts.

  • I cannot put my logics on create scripts, which will be the simplest way, because you cannot know for sure the company, you're creating the opportunity when the create script is fired. The create script is fired server side and I need to fire my logic client side once the company has been selected by the user.

    Maybe you aren’t in the context of a company, and the opportunity web picker fields are empty, or simply you would change the company you are creating the opportunity for.

    In both changes you cannot know the opportunity you have to look to copy values.

    Anyway, as I already solved the problem with a workaround, the question is about Sdata, so often I would retrieve values from the client side and often is a nightmare and want to know if I’m missing something obvious.

    Thanks for your interest

  • I would:

    1. Write an asp page to find the data you want, format it into a JSON object and return the JSON back to the client;

    2. Write a client-side on-change script on the oppo company field that makes an AJAX call to the asp page, accepts and parses the returned JSON object and populates the on-screen fields with the relevant values;

    3. Write a client-side custom content script to call the company on-change script when the page loads if the company field is already populated (ie if the oppo is created in the context of a company).