function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
JasonRogersJasonRogers 

Opportunity.CloseDate being set to today on update call

I have a process that changes some values on Opportunity objects. In the case when an Opportunity is being set to a Purchased Stage from a previously non-Purchased Stage the CloseDate is being changed ON THE SALESFORCE SERVER SIDE to "today". I have looked at the message going across the wire and saw that CloseDate is indeed NOT "today" but rather the same value as it was when I queried for it. Nevertheless, when I log in to Salesforce after completing the update the CloseDate is set to "today."

Does anyone know why this would happen? A configuration setting? Perhaps there is some job/task someone has created that could do this? I don't expect anyone here to know what the task may be, I am asking if that is a possibility.

I have saved the XML for the update and its response and can post that if it would help.

Thanks.

Jason
benjasikbenjasik
Looks at the opportunity stage picklist setup. Is the "type" of the picklist value you are seeting it to "closed/won"? If so, this is the correct behavior. The isClosedFlag should be getting set too.
JasonRogersJasonRogers
This sounds viable. 'Purchased' is a Closed/Won picklist entry. However, I don't get this same behavior when I manually set an opportunity to Purchased in the WebUI. Is this behavior only expected through the WebServices API? (We are using the Enterprise version.)
JasonRogersJasonRogers
I hate to reply to my own post, but I didn't get an answer to my last question.

Benji says it is the expected behavior to set an Opportunity's CloseDate to "today" when it is set to "Purchased" because "Purchased" is marked as a "Closed/Won" type of stage. However, I don't see this behavior in the Web interface. Am I missing something?

I really dislike this behavior because it now forces me to update an opportunity twice. Once for its original update and once to "reset" the CloseDate.
benjasikbenjasik
I have tested this on my org and I see closeDate get set to today for both the web and the API when I set to a stage that is "closed"

Why don't you change the type of Puchased to not be "Closed/Won"?
JasonRogersJasonRogers
I believe that attribute is being used by some reports (filtering on 'Won' opportunities). I have coded a work-around that captures the Purchased ChangeEvent and replays the update with the correct date after the initial update. Thanks for checking in to this for me.