Hi Team,
We want to fetch record id of opportunity and then store it in string array using C#. Could you help us please?
Many Thanks,
Mayur
Hi Team,
We want to fetch record id of opportunity and then store it in string array using C#. Could you help us please?
Many Thanks,
Mayur
Hello there,
Yes, you could achieve this using the webapi: https://docs.microsoft.com/en-us/powerapps/developer/common-data-service/webapi/retrieve-and-execute-predefined-queries#use-custom-fetchxml
So, you could create a view using the UI, download the fetch for that view then encode that fetch and use it with above webapi query.
Please let us know if you have any more questions or please mark this as answered if we have answered your question.
regards,
Hi,
can you please give more details ?
Hi Mehdi,
Actually we have to do it from web API. We have to fetch data from API and then wwe have to add in array. Can we do it from API?
You can also use QueryExpression / Odataquery Endpoint.
QueryExpression -
// Instantiate QueryExpression QEopportunity
var QEopportunity = new QueryExpression("opportunity");
QEopportunity.TopCount = 50;
// Add columns to QEopportunity.ColumnSet
QEopportunity.ColumnSet.AddColumns("opportunityid", "name");
Odata Query endpoint - XXXX.crm8.dynamics.com/.../opportunities
Hi,
I add two lines to your code. (found in your last post)
var fetchData = new
{
willis_probability = "7",
willis_inceptiondate = "01-25-2020"
};
var fetchXml = $@"
<fetch top='50'>
<entity name='opportunity'>
<attribute name='willis_opportunityid' />
<filter type='and'>
<condition attribute='willis_probability' operator='eq' value='{fetchData.willis_probability/*7*/}'/>
<condition attribute='willis_inceptiondate' operator='on-or-before' value='{fetchData.willis_inceptiondate/*01-25-2020*/}'/>
</filter>
</entity>
</fetch>";
EntityCollection result = _serviceProxy.RetrieveMultiple(new FetchExpression(fetchXml));
List<Guid> oppIds = new List <Guid>();
foreach (var c in result.Entities)
{
System.Console.WriteLine(c.Attributes["name"]);
oppIds.add(c.Id);
}
Daivat Vartak (v-9d...
225
Super User 2025 Season 1
Muhammad Shahzad Sh...
91
Vahid Ghafarpour
78
Super User 2025 Season 1