I am able to fetch an opportunity name and opportunityid by doing something like:
SELECT opportunityid, name FROM opportunity WHERE name LIKE '%search term%'.
However, now that I have the opoortunityid in the format '1d527eac-3f61-48cb-809a-12b0e7acb112', I would like to fetch the active stage of the opportunity in the Opportunity Sales Process.
If I also try to fetch stageid, salesstage in the query, they both return null. I also tried selecting
FROM opportunitysalesprocess WHERE opportunityid = '1d527eac-3f61-48cb-809a-12b0e7acb112'
but it returns: Resource not found for the segment "'opportunity sales process'".
How can I select the current/active stage of an opportunity by using the opportunityid?
I used stagename instead of activeStage but this worked, thank you.
Hi btc_dynamics,
Yes after getting the "_activestageid_value " in first request you can retrieve the name of the activeStage name using the GUID of the "_activestageid_value "
Thanks,
Manoj Mane.
Please mark this as VERIFIED if it helps.
Hi,
SELECT stagename FROM processstage WHERE _activestageid_value = 'xyz';
Hi Manoj Mane
Is there a way to do this without using the $expand keyword? (I'm using a middle-man service that doesn't support expanding the record).
For example, could I do something like:
SELECT salesstage FROM {some table} WHERE _activestageid_value = 'xyz';
Thanks
Hi btc_dynamics,
You need to expand the activestageid record in the expand you will get the stagename.
As shown in below query:-
$select=_activestageid_value,name&$expand=activestageid($select=processstageid,stagename)&$filter=_opportunityid_value eq 'opportunnityGUID'
Thanks,
Manoj Mane.
Please mark this as VERIFIED if it helps.
An update on the above. I get some results when I use the plural name opportunitysalesprocesses.
I am now a step further by using the query:
SELECT name, _activestageid_value FROM opportunitysalesprocesses WHERE _opportunityid_value = '{opportunity_id}'
This query gives me a result like:
Now that i have the businessprocessflowinstanceid and _activestage_value, do you know how I can obtain the active stage name?
Hi Manoj Mane
When I go to the following URLs:
my_crm_url/api/data/v9.0/process_name
my_crm_url/api/data/v9.0/opportunitysalesprocess
I still get the following response:
{"error":{"code":"0x8006088a","message":"Resource not found for the segment 'process_name'."}}
{"error":{"code":"0x8006088a","message":"Resource not found for the segment 'opportunitysalesprocess'."}}
I've also tried selecting activestageid and _activestageid_value from opportunity but get the following response:
{"error":{"code":"0x0","message":"Could not find a property named 'activestageid' on type 'Microsoft.Dynamics.CRM.opportunity'."}}
I'm using DQL queries with Kloudless so might need to make multiple calls to one table at a time to get the right data.
This is the process i'm trying to select:
Hi btc_dynamics,
You can refer the below query & attached ss of Opportunity:-
your_crm_url/api/data/v9.0/process_name ?$select=_activestageid_value,name&$expand=activestageid($select=processstageid,stagename)&$filter=_opportunityid_value eq 'opportunnityGUID'
You need to modify the above query with your CRM URL and process name.
Thanks,
Manoj Mane.
Please mark this as VERIFIED if it helps.
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,253 Super User 2024 Season 2
Martin Dráb 230,188 Most Valuable Professional
nmaenpaa 101,156