I want to get the value of manager of the current user and use that value in fetchxml to create a view based on manager of the current user. How can I do that??
*This post is locked for comments
I want to get the value of manager of the current user and use that value in fetchxml to create a view based on manager of the current user. How can I do that??
*This post is locked for comments
Hi Alex,
correct I need this type of filter using fetchXML. Can You please suggest any solution?
Thanks
Aparna
Thank you so much Hemant. But the solution provided by you can be used in javascript. I want to use value of "var fetchXml" in the same FetchXML for filter.
I need to have a view like this:
this manager value will be dynamic.
Thanks
Aparna
Hi Aprna,
Here is the sample code in JavaScript, this give an idea:
function getManager() {
var fetchXml = "<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>" +
"<entity name='systemuser'>" +
"<attribute name='systemuserid' />" +
"<attribute name='parentsystemuserid' />" + //manager
"<filter type='and'>" +
"<condition attribute='systemuserid' operator='eq-userid' />" +
"</filter>" +
"</entity>" +
"</fetch> ";
var encodedFetchXml = encodeURI(fetchXml);
var queryPath = "/api/data/v8.0/accounts?fetchXml=" + encodedFetchXml;
var requestPath = Xrm.Page.context.getClientUrl() + queryPath;
var req = new XMLHttpRequest();
req.open("GET", requestPath, true);
req.setRequestHeader("Accept", "application/json");
req.setRequestHeader("Content-Type", "application/json; charset=utf-8");
req.onreadystatechange = function () {
if (this.readyState === 4) {
this.onreadystatechange = null;
if (this.status === 200) {
var returned = JSON.parse(this.responseText);
var results = returned.value;
if (results.length > 0) {
var managerId = results[0]["_parentsystemuserid_value"];
//TODO: Implement logic for handling results as desired
}
} else {
alert(this.statusText);
}
}
};
req.send();
}
for more details you may use the below link:
www.hbs.net/.../using-fetchxml-in-web-api-queries-via-javascript-f
Thanks
Hemant
Hi Hemant,
<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false">
<entity name="systemuser">
<attribute name="systemuserid" />
<attribute name="parentsystemuserid" />//manager
<filter type="and">
<condition attribute="systemuserid" operator="eq-userid" />
</filter>
</entity>
</fetch>
in this code we retrieved "parentsystemuserid". I want to store this value in a variable and use it later in filter criteria as a dynamic variable value. how can I do that?
Thanks
Aparna
Sure Aparna,
Could you please share your code in detail?
Thanks
Hemant
Hi Hemant,
I am new to fetchXML. Can you please tell me how can I use this manager value? How can I store this value to a variable?
Thanks
Aparna
Hi Aparna,
I guess its data issue, that guide(manager) which is present in the source and not available in the target.
Please have a look here..it may helps you
daxsnippets.wordpress.com/.../dependency-calculation-error
Hemant
Thanks Hemant.
I made the changes in xml file under saved Queries section and made zip solution.
Now when I am trying to import it as a solution it is showing me error as:
"Message There was an error calculating dependencies for this component. Error in saved query with id {0}".
Hi,
wondering if you need this kind of filter:
Hi Aparna,
The below fetchxml will give you the manager of the current user.
<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false">
<entity name="systemuser">
<attribute name="systemuserid" />
<attribute name="parentsystemuserid" />//manager
<filter type="and">
<condition attribute="systemuserid" operator="eq-userid" />
</filter>
</entity>
</fetch>
"use that value in fetchxml to create a view based on manager of the current user"
Do you want to create a view dynamically?
If yes, please go through the below url, this may help you
community.dynamics.com/.../how-to-create-crm-entity-view-programmatically
community.dynamics.com/.../158168
Thanks
Hemant
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,280 Super User 2024 Season 2
Martin Dráb 230,214 Most Valuable Professional
nmaenpaa 101,156