Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Salesforce Standard Order object OpportunityID field not recognized #98

Closed
JeffMTI opened this issue Dec 5, 2014 · 41 comments
Closed
Labels

Comments

@JeffMTI
Copy link

JeffMTI commented Dec 5, 2014

Trying to define a rollup from Order onto Opportunity using the standard Lookup(Opp) field gets Field does not exist on OpportunityId.

@JeffMTI
Copy link
Author

JeffMTI commented Dec 5, 2014

Workaround for now: If you are using Flows to Generate Orders from Opps, you can add a custom Lookup(Opp) field to Order and update the Flow to set the custom lookup field to the Opp.Id in addition to setting the standard OpportunityId field. Base your rollups on the custom field.

@afawcett
Copy link
Collaborator

Yes this field is totally not accessable via Apex, most frustrating. Another option to workaround this would be to create a Field Update Workflow i think.

@JeffMTI
Copy link
Author

JeffMTI commented Dec 16, 2014

I have no problem accessing and using the Order.OpportunityId field in any of the Apex I have written.

@afawcett afawcett reopened this Dec 16, 2014
@afawcett
Copy link
Collaborator

Hmmmm, let me look closer into this then, i did a check in Annonymous Apex in Developer Console and it didn't compile. I'll take a closer look....

@afawcett afawcett added the bug label Dec 16, 2014
@afawcett
Copy link
Collaborator

afawcett commented Feb 7, 2015

Fixed in v1.17.

screen shot 2015-02-07 at 23 35 51

@afawcett afawcett closed this as completed Feb 7, 2015
@karenhite
Copy link

@afawcett I was not able to do this from my org. I tried to place OpportunityId as the relationship field and it did not exist still. Could you please guide me with the steps on how to make it work? I'm trying to create a roll up summary for the field Next Activity Date that will be allocated within the Opportunity object (Parent) and the Child Object is Task.

@DanDonin
Copy link
Contributor

DanDonin commented Mar 22, 2017 via email

@karenhite
Copy link

screenshot 2017-03-22 07 59 17

Is this what you are saying?

@DanDonin
Copy link
Contributor

DanDonin commented Mar 22, 2017 via email

@karenhite
Copy link

Did not seemed to work. I have 2 Open activities and the Next Activity Date field is not getting filled out.
screenshot 2017-03-22 08 01 29

@DanDonin
Copy link
Contributor

DanDonin commented Mar 22, 2017 via email

@karenhite
Copy link

Tried to do that and still the field is not being updated. Also, when the rollup summary is active, I'm not able to edit or create any tasks.

@DanDonin
Copy link
Contributor

DanDonin commented Mar 22, 2017 via email

@karenhite
Copy link

screenshot 2017-03-22 08 10 00
It is active and the trigger has been deployed. This is the error:

@DanDonin
Copy link
Contributor

DanDonin commented Mar 22, 2017 via email

@karenhite
Copy link

I'd like to see the min of open activities. Will First allow me to do so?

@DanDonin
Copy link
Contributor

DanDonin commented Mar 22, 2017 via email

@karenhite
Copy link

The closest of all of the open activities. If I have 3 dates:

  1. March 22nd
  2. March 30th
  3. April 1st
    I'd like to see March 22nd as the next activity date

@DanDonin
Copy link
Contributor

DanDonin commented Mar 22, 2017 via email

@karenhite
Copy link

Yes, even if it's in the past (overdue)

@DanDonin
Copy link
Contributor

DanDonin commented Mar 22, 2017 via email

@karenhite
Copy link

:( I tried to do it with First but now it gives me an error: Error:Master and detail fields must be the same field type (or text/Id based) for First or Last operations

I checked both fields (ActivityDate) and Next Activity Date and they are both Date/Time fields.

@DanDonin
Copy link
Contributor

DanDonin commented Mar 22, 2017 via email

@karenhite
Copy link

Awesome. Ok so I was able to fix this and it is showing a date BUT it's showing the first activity date. I want it to be the first activity date of Open Activities not All Activities. How can I filter this?

@DanDonin
Copy link
Contributor

DanDonin commented Mar 22, 2017 via email

@karenhite
Copy link

It worked! Thank you so much!

@karenhite
Copy link

Now my only concern is that this trigger is affecting another workflow. I got this error below.
How can I make sure to not affect the workflow?

FlowApplication [email protected]
10:50 AM (16 minutes ago)

to me

Add to Salesforce Tracking Follow-up
Error element myRule_1_A1 (FlowRecordCreate).
This error occurred when the flow tried to create records: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY: dlrs_TaskTrigger: execution of AfterInsert caused by: System.DmlException: Update failed. First exception on row 0 with id 0065000000fOQlLAAW; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, You cannot update Closed Won Opportunities, please contact your System Administrator if an update needs to be made.: [] (dlrs) . For details, see API Exceptions.
This report lists the elements that the flow interview executed. The report is a beta feature.
We welcome your feedback on IdeaExchange.
Flow Details
Flow Name: Closed_Won_Opportunity_Process
Type: Workflow
Version: 13
Status: Active
Flow Interview Details
Interview Label: Closed_Won_Opportunity_Process-13_InterviewLabel
Current User: Tony Diaz (0055000000679jU)
Start time: 3/22/2017 9:50 AM
Duration: 0 seconds
How the Interview Started
Tony Diaz (0055000000679jU) started the flow interview.
Some of this flow's variables were set when the interview started.
myVariable_old = 0065000000fOQlLAAW
myVariable_current = 0065000000fOQlLAAW
ASSIGNMENT: myVariable_waitStartTimeAssignment
{!myVariable_waitStartTimeVariable} Equals {!Flow.CurrentDateTime}
Result
{!myVariable_waitStartTimeVariable} = "3/22/2017 9:50 AM"
DECISION: myDecision
Executed this outcome: myRule_1
Outcome conditions: 1 AND (2 OR 3 OR 4 OR 5)

  1. {!myVariable_current.StageName} (Closed Won) Equals Closed Won
  2. {!myVariable_current.Lead_Channel__c} (Telemarketing) Does not equal Internal
  3. {!myVariable_current.LeadSource} (Telemarketing) Does not equal Cross Sell
  4. {!myVariable_current.LeadSource} (Telemarketing) Does not equal Up-sell
  5. {!myVariable_current.LeadSource} (Telemarketing) Does not equal Win-back
    Logic: Advanced Logic (1 AND (2 OR 3 OR 4 OR 5))
    DECISION: myRule_1_pmetdec
    RECORD CREATE: myRule_1_A1
    Create one Task record where:
    ActivityDate = {!formula_6_myRule_1_A1_ActivityDate} (March 22, 2017)
    Description = Send the Welcome Email to the appropriate individual as this Opportunity is Closed Won.
    OwnerId = {!myVariable_current.OwnerId} (0055000000679jUAAQ)
    Status = Open
    Subject = Send Welcome Email
    WhatId = {!myVariable_current.Id} (0065000000fOQlLAAW)
    Result
    Failed to create record.
    Error Occurred: This error occurred when the flow tried to create records: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY: dlrs_TaskTrigger: execution of AfterInsert caused by: System.DmlException: Update failed. First exception on row 0 with id 0065000000fOQlLAAW; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, You cannot update Closed Won Opportunities, please contact your System Administrator if an update needs to be made.: [] (dlrs) . For details, see API Exceptions.
    Salesforce Error ID: 1687453295-63410 (-736724398)

@DanDonin
Copy link
Contributor

This is a process builder that you have that is failing. You can bring a formula down to the task that shows if an opp is closed and exclude dlrs where the opp is closed, or you can set up your flow to not fire when that dlrs field is being updated.

@karenhite
Copy link

Ok so I have the following things that are affecting:

  • Validation Rule in the Opportunity Object that does not allow users to edit Closed Won Opps:
    AND(
    ISPICKVAL(PRIORVALUE(StageName),"Closed Won"),
    NOT(OR(
    $Profile.Id = "00e50000001A5gA",
    $Profile.Id = "00e50000001QOJf"))
    )&&
    NOT(ISCHANGED( Next_Scheduled_Activity_Date__c ))&&
    NOT(ISCHANGED( Client_Questionnaire_Link__c ))
  • Process Builder in the Opportunity Object that creates different tasks for users when an opportunity is placed as Closed Won

How would I be able to make the exemption so this error is not applicable?

@DanDonin
Copy link
Contributor

What causes the flow to fire?

@karenhite
Copy link

The Stage to be marked as Closed Won

@DanDonin
Copy link
Contributor

Does it fire on every edit? Under Advanced on the Criteria in PB select the Do you want to execute the actions only when specified changes are made to the record? This will prevent it from running every time the record is edited and only when the record used to not meet the criteria and now does meet the criteria.

@karenhite
Copy link

This was checked already. When we got the error it was the first time the opportunity was being placed with Stage= Closed Won.

@karenhite
Copy link

I was reading about the Process Builder Calculation Mode. Would it help to include this action in the PB that is giving me an error?

@DanDonin
Copy link
Contributor

Not really, you are running into order of operations errors. PB is trying to make an update, and when PB makes that update it creates a Task, that triggers DLRS, that then runs into an error due to the validation rule of not able to update the opp. Need to figure out a way to let DLRS around the validation rule.

@karenhite
Copy link

Opportunity Validation Rule: Cannot Edit Closed Won OppsxAND(
ISPICKVAL(PRIORVALUE(StageName),"Closed Won"),
I Just changed the VR to this and moved the DLRS to Real Time to see if it allows me to.
NOT(OR(
$Profile.Id = "00e50000001A5gA",
$Profile.Id = "00e50000001QOJf"))
)&&
NOT(ISCHANGED( Next_Scheduled_Activity_Date__c ))&&
NOT(ISCHANGED( Client_Questionnaire_Link__c )&&NOT(ISCHANGED(NEXT))

@karenhite
Copy link

Tried to test it without luck. The error appeared again.

@DanDonin
Copy link
Contributor

Try turning off the VR 100% and see if the error still happens.

@karenhite
Copy link

Once the VR was deactivated, everything is running smooth.

@DanDonin
Copy link
Contributor

Yeah so the issue if trying to find a way to systematically have the VR allow DLRS to do its thing. The problem is DLRS will run as whatever user triggers it.

@antoniobarrosjr
Copy link

Hello, I´m facing this same problem and I was not able to find the solution. the case seems to be closed. Can someone help ?

Thanks,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants