0

There is a master detail relationship between Opportunity and Work Order with opportunity as the master. I have created a custom list button on Work Order related list that will create new Work Order and prefill some fields from Opportunity. Requirement is such that the user must be able to change the prefilled values if needed.

URL:

/lightning/o/WorkOrder__c/new?defaultFieldValues=
Opportunity__c={!Opportunity.Id},
event_Overview__c={!Opportunity.Event_Overview__c},
Shoot_Start__c={!Opportunity.Estimated_Start_Time__c},
Shoot_End__c={!Opportunity.Estimated_End_Time__c}

Problem 1: The custom list button on related list navigates me to a blank page with weird URL. I don't stay on the same opportunity page.

I used the same URL on a detail page button on Opportunity and found that it stays on the opportunity page. But the list button on Work Order related list with the same URL does not. I wish to stay on the same opportunity page if user clicks on 'Cancel'.

Problem 2:

I am able to fill all fields except the date time fields. The date time fields are getting filled incorrectly and its not allowing me to create a record due to error (The datatype of fields of both work order and opportunity is date time). The time is getting added in the date portion. Please guide. Thank You!

sc2

1
  • I was able to solve the date time problem by making slight modification to the URL. But the navigation problem still remains. Shoot_Start__c={!TEXT(DATEVALUE(Opportunity.Estimated_Start_Time__c))}T{!TEXT(TIMEVALUE(Opportunity.Estimated_Start_Time__c))}Z
    – Koustubh
    Jun 23 at 10:24
0

Solve the url navigation by adding the following at the end of the URL:

&backgroundContext=%2Flightning%2Fr%2FOpportunity%2F{!Opportunity.Id}%2Fview

Complete URL will look as follows:

/lightning/o/WorkOrder__c/new?defaultFieldValues=
Opportunity__c={!Opportunity.Id},
event_Overview__c={!Opportunity.Event_Overview__c},
Shoot_Start__c={!Opportunity.Estimated_Start_Time__c},
Shoot_End__c={!Opportunity.Estimated_End_Time__c}&backgroundContext=%2Flightning%2Fr%2FOpportunity%2F{!Opportunity.Id}%2Fview

Note that there should not be any spaces or carriage returns in the URL.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.