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
Jamie Marshall 4Jamie Marshall 4 

id hack - pull fields from child for new parent record

My organization sells cars.

After an opportunity has been won, a child record called "Lease Returns" is created from a related list to track the customer. When the lease is up we need to create a new opportunity and we do so from the opportunities related list on the Lease Returns Object. So there is a 1-1 relationship between this parent and child.

New Opportunity -> New Lease Return -> New Opportnity -> New Lease return -> New Opportunity -> New Lease Return -> etc......

When I create a New lease return I pull info from the preceeding opportunity using formula fields. However when I create a new opportunity everything is blank. 

I've been trying to use URL hacking to prepopulate the New opportunity fields but the child records fields arent reconized. What is the way to do this?

I'm using professional edition
Anupam RastogiAnupam Rastogi
Hi Jamie,

Are the following opportunities and Lease return records created manually by the user or automatically by the system?

Thanks
AR
Jamie Marshall 4Jamie Marshall 4
Sorry for the late reply, I was out of town and couldn't post from my phone for some reason...

The records are currently created by users manually clicking on the "new" button on the respective related lists at the bottom of the detail page. 
Anupam RastogiAnupam Rastogi
Hi Jamie,

From my past experience, I would like to share few points for your consideration while pulling data multiple levels down - 
1. Formula Fields are good to have fields in scenarios where we need to pull information from multiple fields into one field.
2. This incldues scenarios where the pulled info exists in different related objects.
3. As Formula Fields are based on different objects' data and are calculated at runtime, it might cause issues when multiple levels of info is pulled. The reason could be wrong configuration.

For reasons stated above, I would suggest you to do the following instead - 
1. Create regular fields for the Opportunity and Lease Return objects rather than Formula Fields.
2. Update these fields when the User creates the new record for them from the other object. To achieve this, you can use Process Builder to avoid any coding.

Advantage of using regular fields instead of Formula fields - 
1. As Formula fields are based on other fields, therefore if any of the other field is blank or not holding proper value at an instance of time, the Formula field will also show improper value.
2. Regular fields updated on record creation will continue to hold the initial values until they are not manually or systematically updated by someone.

For your help, I am also sharing some general steps to create a Process using the new SFDC Process Builder - 
1. Navigate to Set Up -> Create -> Workflows & Approvals -> Process Builder, and create new Process with details like -
         Object = [Name of the Object] Like Opportunity, Lease Return
         Start the process = only when a record is created
2. Choose criteria for allowing only specific records to enter this process. Like in your case you need to initialize the fields with the data of the other object without checking any conditions. So you can choose the following - 
         Criteria for Executing Actions* = No criteria—just execute the actions!
    If you have any conditions to check, you can include them instead.
3. When the criteria is true, add action to Update Records. Add the fields that you wish to update from the other object's fields. 
4. Activate

And you are done. Now test it by creating new records for Oppotunity then Lease Return then Opportunity and then Lease Return.

Thanks
AR

If this reply helps you resolve the problem then please mark it as best answer.
Jamie Marshall 4Jamie Marshall 4
Thanks for the response AR.

Unfortunately this solution is not applicable to us on Professional Edition. Professional organizations do not have access to workflows. 
 
I believe from my research the only way to do this on professional is with a URL hack. However, due to the parent/child relation ship between opportunities/lease returns you can not pull information from the child. Records do not get created in an endless circle. When a child (lease returns) creates a new parent record (Opportunity) that parent record appears to be unique. 

For instance. you can not make a formula field on that parent that references the child that created it. You can only reference children that that parent creates from there on out. 

As I said, I think the only way to solve this will be URL hack. However run-time queries such as {!Lease_Return__r.Current_Vehicle_Make__C} won't return a value because this query isn't looking for the record that created the opportunity. Its looking for a child that hasn't been created yet.
Children can't be parents of their parent object. So how do a create a new unique parent record and fill it with info from the child of another record? Can we get values before run-time of the new record and then write them at run-time? Do I correctly understand how Salesforce PE handles these relationships? There has to be a solution somewhere here. 

Is it just possible to do a URL hack and pull info from unrelated data. If that is possible, then what I'm trying to do should be.
 
Thanks,
 -Jamie Marshall
 
Anupam RastogiAnupam Rastogi
Hi Jamie,

As you mentioned in the initial post that the opportunity related list is present on the Lease Return detail page as well, from where you create the new opportunity for that Lease Return. Therefore there is some relationship that you have in your Org where Lease Return is the parent of the Opportunity object.

My next suggestion is to use Trigger to update the fields.

For Example, if you are on Lease Return detail page and you click New on the Opportunity related list.
A trigger will initialize the Opty fields whichever you code with values from that Lease Return record using the relationship present.
On saving the opportunity record, the fields will be saved with the respective values.

I have not worked on URL Hacking so cannot advice in that direction. So try the option above, if you think it worth. Let me know if you need any help in coding, that is my area of expertise.

Thanks
AR
Jamie Marshall 4Jamie Marshall 4
Thanks again, but custom triggers are also not avialable in Professional Edition. 

And where a record is created does not specify its relationship in the database. Most commonly it can, but many time it doesn't. If it did, the database would break easily due to layering problems. 
Jamie Marshall 4Jamie Marshall 4
The vary problem here is that Opportunities cannot be a child of Lease Returns. Otherwise I could easily reference the information I needed at runtime. Since I can't the relationship does not exist. What related lists say doesn't matter, they're just links.