Webservices query

I'm doing a data import/update using a custom application which works via webservices and I've hit a problem. My import data contains a field called region. That region contains data like:

Sri Lanka
India

There are many more. I use this field to do a lookup on an entity for a record. The problem is that region is a drop down list in CRM called comp_c_tregion and the code is a value like:

A1
B2

The caption codes bear no relationship to the translation. There is a reason for this which is not relevent to this. The problem I have is that when I get given "Sri Lanka" in the input data, I need to do a query over webservices that uses the equivalent caption code instead of the data passed in. I cannot simply hard code this in the application as the data in comp_c_tregion does get added to as new regions come on board. I need the application to be able to dynamically get the data out of metadata but the custom_captions table is not available over web services. I could make the table available over webservices but I don't really want to. There has to be a way of querying metadata over webservices to get the caption code for a given translation.

Does anyone have any idea?

I have queried the value of the drop down directly from the company entity using the idea here: https://community.sagecrm.com/partner_community/b/hints_tips_and_tricks/archive/2008/08/05/selection-lists-in-web-services.aspx

However, as the article points out, the return from getdropdownvalues("company") gives me all the fields and I can do a nested loop to get the values from the required field in there but it gives me the translations only. That is fine, but once I find the translation that matches the value "Sri Lanka" I need to query CRM's metadata to get the capt_code for that translation.

Thanks.

  • 0

    Hi ,

    You can implement this functionality using any of the following ways :

    1) Explore Custom_ Captions entity through CRM in Web Service.

    2) You can configure the Caption Name and Caption Code in Web. Config file using parameter and based on the condition mention the appropriate caption code in web services.

    Hope this helps!

    Regards,

    Dinesh

  • 0

    Lee

    Ooops.. Sorry. And to be fair there are loads of articles on Web Services coding! But I'll make a note that I should look again at this area in the next set of articles.

  • 0

    Jeff,

    That's the article I already linked in my post and I've referred to it heavily in my code already :) It only gives me the translation though. I need to get the caption code. Great article though. There are too few documents regarding webservices coding.

    Dinesh,

    Custom_Captions by default isn't web services enabled. I could make it that way but I'd rather not. If there is no other way I will do that but for now, I don't want to. The table is blocked from web services for a reason.

    With regards to 2, do you mean physically add the field and it's contents to the web.config? If so, will that require manually updating when new regions come on board? I was quite surprised when I used the dropdownvalues data type and looped through all the dropdowns on the company entity that the return is just the translation and not a collection of translation and caption code.

    Thanks.

  • 0

    Cheers Jeff. You're a legend :)

    I've read lots of them and to be fair they're pretty good but I'd like to see a developer guide that explains the functions and methods available like there is for ASP coding.

    I've come up with a compromise with my customer at the moment where they will pass in the codes which will make my life a lot easier. Not all tables are available over web services and I know I can just set the flag to make them available. Do you know of any good reason why I shouldn't make the custom captions table available? My thinking is that meta data tables shouldn't be directly available just for another level of security in case some vulnerability is found.

    Thanks.