-1

MY Fetch xml is as follows and i'm using fetchUtil to fetch results. But in the results link entity results are always concatenated with schema name. How get string values without schema name ?

   <fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false">
   <entity name="xxx_opportunityresource">
   <attribute name="xxx_opportunityresourceid" />
<attribute name="xxx_name" />
<order attribute="xxx_name" descending="false" />
<filter type="and">
  <condition attribute="xxx_opportunity" operator="eq" uiname="First Opp" uitype="opportunity" value="{7904E53C-A7AB-E111-8DF0-00155D01AB06}" />
  <condition attribute="xxx_opportunityresourcestatus" operator="eq" value="5" />
</filter>
<link-entity name="xxx_consultant" from="xxx_consultantid" to="xxx_resource" visible="false" link-type="outer" alias="a_7cb2d7e74eabe1118df000155d01ab06">
  <attribute name="xxx_fullname" />
</link-entity>

Result comes in following format

stex_fullnamestex_consultantJohn Mark John"

Greg Owens
  • 3,878
  • 1
  • 18
  • 42
Yasith
  • 117
  • 1
  • 13
  • Why not try **XrmServiceToolkit** is a read documentation https://xrmservicetoolkit.codeplex.com/documentation ... more easy work js + fetchxml! – KingRider Jun 20 '16 at 18:42

1 Answers1

0

I presume you are referring to the library referenced here?

Sounds like you are simply using the wrong property to access the value. Post the line that actually generates the output you mention below and I can show you what to correct it to.

Result comes in following format

stex_fullnamestex_consultantJohn Mark John

Greg Owens
  • 3,878
  • 1
  • 18
  • 42
  • I'm using the reference library you mentioned here. Below are the output that generates from this library. Here are the outputs in different formats. consultantInstances[i] { guid : "xxxxxx-a7ab-e111-8df0-xxxxxxx", logicalName : "xxxx_opportunityresource", attributes : {...} } consultantInstances[i].attributes { xxxx_opportunityresourceid : {...}, xxxx_consultant1.xxxx_fullname : {...}, xxxx_name : {...} } consultantInstances[i].attributes["xxxx_consultant1.xxxx_fullname"] { type : "a:AliasedValue", value : "xxxx_fullnamexxxx_consultantFirst Consultant" } – Yasith Jun 15 '12 at 19:19
  • but which line *in your code* results in the output you posted `stex_fullnamestex_consultantJohn Mark John` – Greg Owens Jun 15 '12 at 21:42
  • Here value shows in the above mentioned format. Here it shows as "xxxx_fullnamexxxx_consultantFirst Consultant". Actual value should be First Consultant but it shows with schema name. consultantInstances[i].attributes["xxxx_consultant1.xxxx_fullname"] { type : "a:AliasedValue", value : "xxxx_fullnamexxxx_consultantFirst Consultant" } – Yasith Jun 18 '12 at 06:22
  • I need a more complete code snippet. Show me your JScript where you get the full results and then show me where you declare `consultantInstances` etc... – Greg Owens Jun 18 '12 at 10:53
  • Actually, while I'm guessing... try this: `var myConsultant = consultantInstances[i].attributes["xxxx_consultant1.xxxx_fullname"].value.Value;` – Greg Owens Jun 18 '12 at 10:55
  • This is the code snippet to retrieve values. var consultantInstances = fetchUtil.Fetch(fetchXML); if consultantInstances && consultantInstances.length > 0) { for (var i = 0; i < consultantInstances.length; i++) { consultant.FullName = consultantInstances[i].attributes["xxxx_consultant1.xxxx_fullname"].value; } } – Yasith Jun 19 '12 at 04:20
  • You're making this very hard ;-) In what way did it not work - was it still the wrong value? Did it raise an error? I can't recreate your error here as I do not know your entity model. That means I rely on you being very clear when you describe things :) – Greg Owens Jun 19 '12 at 10:58
  • I have mentioned everything that I have. Fetch XML and data retrieval codes are given here. Anyway I was able to get the correct value by simple string replace function. Anyway I'm looking forward to get help from someone to do this very easily. To get the required value using string replace functions are given below. var FullName = consultantInstances[i].attributes["xxxx_consultant1.xxxx_fullname"].value.replace("xxxx_fullnamexxxx_consultant", ""). But this is not a good practice and there should be a way to get value without string manipulation. – Yasith Jun 19 '12 at 12:23
  • I really am just guessing, but based on the code [here](http://www.stefanpienaar.co.za/Uploads/FetchXmlJavascript/FetchXml_FetchUtil.txt), my final suggestion (which admittedly isn't consistent with the sample values and properties you have provided), is this: `var FullName = consultantInstances[i].attributes["xxxx_consultant1.xxxx_fullname"].childNodes[2].childNodes[2].text;` – Greg Owens Jun 19 '12 at 13:43
  • This didn't work and there is no childNodes method in return value. Return value has only, type : "a:AliasedValue" and value : "xxxx_fullnamexxxx_consultantFirst Consultant" fields. I think we should find out why this "xxxx_fullnamexxxx_consultant" part is concatenated in value field. Actual value should be "First Consultant" – Yasith Jun 20 '12 at 12:36