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
Mikey999Mikey999 

Setting Page Layout from another object

I have an object called RMA, once the RMA form is filled out the person working with the RMA has to add an RMA Product. We have 3 different types of RMA's each type relates to they page layout. ie RMA Needs Inspection,  RMA New Items to be returned to stock,  RMA Warranty Return Process.

 

What I would like to know, I have a field on the RMA object called RMA Type (picklist) with three options ie. The RMA is for New Items to be returned to stock, can I set it so that when they click on the Add RMA Product, it will automatically open the first page layout of the RMA Products? And of course the same for the three different types. I do not want the user to have to choose the page layout if at all possible. I do not have a field on the RMA yet for the type, but can add this.

Thank you!

Rahul_sgRahul_sg
You can do it using visualforce by over riding the buttons. Another option would be to define custom buttons(content source : URL) and pass the fields Id values.
cmoylecmoyle

My Assumption:

What it sounds like is that you have 2 related objects, with the parent being the RMA and the child being RMA Product with a lookup field to RMA. After a user fills out the RMA form, then you want them to add a related RMA product record and have the page layout of the product record to be dependent on the RMA Type field select in the parent record.

 

My Solution:

Without overwriting any pages with visualforce, there isn't really a clean way to do this IMO. Page layouts are dependent on the cross reference of Profile and Record Type. However, you can set the record type in the URL of the New RMA Product page and bypass the option to select a record type. What I would do is create a new custom button on the RMA object and have it be a URL to the New Product page with the logic of mapping the RMA type to the RMA Product Record Type. So the button would look something like this:

 

IF(ISPICKVAL(RMA_Type__c, 'RMA Needs Inspection'), '/a0A/e?RecordType=xxxxxxx',
      IF(ISPICKVAL(RMA_Type__c,'RMA New Items'), '/a0A/e?RecordType=xxxxxxxxx',
             IF(ISPICKVAL(RMA_Type__c,'RMA Warranty Return Process'), '/a0A/e?RecordType=xxxxx')))

 So in your RMA Product object you would map a set of page layouts to different record types, then pass the record type id's into the above code based on the selection.

           

Mikey999Mikey999

Exactly that is fantastic I will try that.  I already have the URL hack for the record types I was gonig to create 3 record types for the RMA and put a custom button on each for the url hack, but this will be much much better if it works.  Thank you, I will let you know if it works.

cmoylecmoyle

Keep in mind, you'll be using hard coded id's. If the code is deployed elsewhere, or packaged, then this button will need to be udpated.

Mikey999Mikey999

Hmm I am a bit perplexed I get url is too long or broken.

 

When I put just this in a button

 

/a0p/e?CF00N70000002ViYh={!RMA__c.Name}=&CF00N70000002ViYh&RecordType=012700000009k3e - The button works, but when I try  it in the formula I get the error.  It might be something silly but I can't seem to figure it out.  I checked spelling, field type, field name all correct.Thank you!

 

IF(ISPICKVAL(RMA_Type__c, 'RMA Needs Inspection'), '/a0p/e?CF00N70000002ViYh={!RMA__c.Name}=&CF00N70000002ViYh&RecordType=012700000009k3Z', IF(ISPICKVAL(RMA_Type__c,'RMA New Items'), '/a0p/e?CF00N70000002ViYh=012700000009k3e{!RMA__c.Name}=&CF00N70000002ViYh&RecordType=012700000009k3e',
IF(ISPICKVAL(RMA_Type__c,'RMA Warranty'), '/a0p/e?CF00N70000002ViYh=012700000009k3e{!RMA__c.Name}=&CF00N70000002ViYh&RecordType=012700000009k3j')))

cmoylecmoyle

/a0p/e?CF00N70000002ViYh={!RMA__c.Name}=&CF00N70000002ViYh&RecordType=012700000009k3Z

 

The problem might be with the equals symbol shown above.

 

Check all your URLs and make sure the format is /a0p/e?a=z&b=y&c=x...

Mikey999Mikey999

Hmm still not sure maybe I will stop for the day lol.  checked the URL's they are working correctly, the url's work wtih and without the = sign.  It has to be something I am just missing, I did have an error though I had the record type for 2 of them twice but I changed that.

 

IF(ISPICKVAL(RMA_Type__c, 'RMA Needs Inspection'), '/a0p/e?CF00N70000002ViYh={!RMA__c.Name}=&CF00N70000002ViYh&RecordType=012700000009k3Z',
IF(ISPICKVAL(RMA_Type__c,'RMA New Items'), '/a0p/e?CF00N70000002ViYh={!RMA__c.Name}=&CF00N70000002ViYh&RecordType=012700000009k3e',
IF(ISPICKVAL(RMA_Type__c,'RMA Warranty'), '/a0p/e?CF00N70000002ViYh={!RMA__c.Name}=&CF00N70000002ViYh&RecordType=012700000009k3j')))