4

What i want to do should be easy to do via URL hack, but looking at legitimate ways of doing this. I want to create a child invoice line item from parent invoice and set the save url to the parent invoice.

I had the thought of approaching it using URLFOR and $Action but can't even get it to set the parent id. Saw some old threads on success that indicated you could pass the field IDs as parameters but system won't allow for save, and this seems little different from URL hack. Can't find any docs on what url parameters, if any, are officially supported on $action.

So, then, what is the supported means of doing this? Do I have to replace the line item page w a vf page and use an extension to override the save behavior? Is there a simpler supported means of doing this?

2
  • So you have tried: {!URLFOR($Action.InvoiceItem__c.New, null, [saveURL='/'&Invoice__c.Id]}? You need to use merge syntax correctly to get it to work.
    – sfdcfox
    Commented Oct 11, 2015 at 14:30
  • @sfdcfox I tried that, but the lookup to invoice from the line item does not get populated. So I tried passing in the invoice id via parameters but no luck. Would not let me save if I used the URL hack style of fieldid+fieldid_lkid and couldn't figure out a way to get it to simply link the child to the parent. Fwiw it is a m-d relationship. I figured I wouldn't be able to populate custom fields, but didn't think setting the relationship would be an issue. I'm using a list button on the invocie record, from the invoice line item related list.
    – gorav
    Commented Oct 11, 2015 at 15:52

1 Answer 1

0

I recommend that you keep in mind that URL hacks are going away. A year or two years at most from now, they'll likely be gone entirely. So, if looking at the "big picture", you genuinely want to avoid using URL hacks as someone will have to come in behind you at some point and fix them.

That being said, if you also want to set a URL linking the child to the parent, in my experience, I've typically done that using a trigger, but then I don't know what kind of "child" record you're trying to create as there are different kinds of "children". If it's a M-D detail record, it's very different than if it's a related record that's a child of the parent record. The latter requires an insert of the new child record followed by an update of the parent record to link it to the child if you want to have cross-references that explicitly link the two.

If you're trying to create a record that you want to save on the parent's detail record page, that's an entirely different story and it's unclear to me exactly which it is you wish to do since you've not included code showing what's you've tried that didn't work for you or a flow diagram of the objects involved.

3
  • Thanks @crmprogdev, getting back after a break. Agreed re: url hack. I'm trying to go legit but going to visualforce just to set save url is a tough sell. This is a M-D relationship between invoice and invoice line item. I create the line item from a related list on invoice. I would want the user to return to the parent invoice when the child is saved, and for the relationship to the parent to populate normally as it would w/ the standard new button. Its possible using a publisher action, but until we can run those from buttons its not usable. I think the VF would be simple, but still :(
    – gorav
    Commented Nov 9, 2015 at 14:51
  • Are the child invoices on a related list or are they part of the parent invoice? If on a related list, I'd think this would be much simpler to do by clicking on the create a new related record link. If you don't like the Global Action option, a visual flow would seem to be another means of accomplishing what you want that returns you to the same location.
    – crmprogdev
    Commented Nov 9, 2015 at 15:04
  • They are a separate object, so related list. The new button works fine, I just want the user taken back to the parent record on save. It's so easy w a URL hack that it's hard to justify even building a flow for it. I will repent later! It's not that I don't like the global action option, it just doesn't work.
    – gorav
    Commented Nov 9, 2015 at 18:06

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .