+ Start a Discussion
wpatterswpatters 

Create a custom link dynamically?

Hello everybody, I was just wondering, is it possible to create a new custom link on one page when you create a new object on another? I have a custom object called information, and all it has is a large text area with a name. What I want is for it to create a new custom link on my opportunity object for onClick Javascript when a new information entry is added. Is it possible to create a custom link dynamically, with a workflow rule or something? Or maybe an s-control? This would make my life a lot easier, thanks!
MVJMVJ
I am not 100% sure what you are trying to achive but you can create a dynamic custom link.  We are doing it on our opportunity page where we pull data from the Opportunity and Account objects to pass data to a web page. 

All you need to do is go to setup --> Customize --> Select your object --> Buttons and Links --> New

Select the behavior of the link and put in the link details

I.E:

http://www.someaddress.com?Agn={!Opportunity.Id}&Cagn={!Opportunity.AccountId}&Nr=&Orc={!User.ORC_Code__c}&Ct=&On=&Bsn=&Dn={!Account.D_U_N_S__c}&Du=&Sr1=&Sr2=&Sr3=&Sr4=&Sr5=&Rn={!User.FirstName} {!User.LastName}&Rp={!User.Phone}&Rid=&Re=&Cn={!Account.Name}&Ca1={!Account.BillingStreet}&Cc={!Account.BillingCity}&Cst={!Account.BillingState}&Cz={!Account.BillingPostalCode}&Crck={!Opportunity.Credit_Recommendation__c}&Amnt={!TEXT( Opportunity.Amount )}&Ard={!IF( LEN( TEXT( MONTH( Opportunity.CloseDate ) ) )<2 , "0" & TEXT( MONTH( Opportunity.CloseDate ) ), TEXT( MONTH( Opportunity.CloseDate ) )) }/{!IF( LEN( TEXT( DAY( Opportunity.CloseDate ) ) )<2 , "0" & TEXT( DAY( Opportunity.CloseDate ) ), TEXT( DAY( Opportunity.CloseDate ) )) }/{!TEXT( YEAR( Opportunity.CloseDate ) )}


Hope this helps. 

Mike
wpatterswpatters
Ok so I have an object called information, which is just a name and a large text area. What I'm trying to do is make it so that when a new information row is created, a new custom link referencing the information is automatically created on my opportunities page. It's for my boss's sake, so he doesn't have to get me to create the link for him when he wants to make a new information field.
SteveBowerSteveBower

When the boss creates a new Information record are you trying to create a Link/Button which would appear on *every* Opportunity object so they all have buttons to point to the new information?  Or is the information specific to *one* opportunity?

From your posts I'm thinking you want the former.


You could create a post-insert trigger on the "information" object which would create a new Weblink record which would be of type URL, and the URL would be pointing to the ID of the information record you just created.  So, each time a new information row is created a new weblink (or button) would be created for the Opportunity object which pointed to the information record.

However, and this is a big however, adding that newly created weblink to the appropriate Page Layout for the Opportunity object type would also have to be done.  While that should be possible through the Metadata interface, you're really stepping outside the realm of the types of things that are intended to be done on the fly as part of a trigger.  You can't access the Metadata api that way anyway.

So, if you REALLY want that type of function, you could write an embedded visualforce component that could be placed on the Opportunity page.  That component could then query all the information records and present a set of buttons/links (or a pulldown list, etc.) for the boss to select, and then jump to that page.  You could also do this with an s-control, but don't, use vf.



If you want the latter, each information record is associated with one Opportunity record, then you should instead consider adding an Opportunity lookup field to the information record.  That way when the boss enters information, he associates it with an opportunity.  When looking at each opportunity, the Information records would appear in a related list and he could navigate to them from there.

It's not 100% clear (to me anyway) which one you're trying to do, but I hope this helps.  Best, Steve.