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
gizmo100gizmo100 

Formula to auto generate links ( or lines) based on a number entered in other field?

 

Hi,

 

 

I have a text  field with a link (for example) www.salesforce_1.com

 

And

 

I have a number field where I can enter 20, 35 or 100 depending on the record. (let´s suppose I have entered 25)

I would like to create a formula to obtain the 25 lines automatically: (all lines/links in the same field)

 

 

www.salesforce_1.com

www.salesforce_2.com

www.salesforce_3.com

www.salesforce_4.com

etc......

 

Any ideas??

 

Thank You!

Gizmo

 

 

 

PilkoTechPilkoTech

You could do it, but it would be ugly since there isn't any conditional looping logic for formulas.

 

For this to work, you'd have to be guaranteed there was something in common with all the URLs. For simplicity's sake, we're going to say that the position of the number will be 4 characters from the end of the URL. If you've got to find the "_" character, it's that much more complex.

 

There is a 3900 character limit on formula fields, so you're not going to be able to generate more than 43 of these. Fewer if your rules to find the strings are more complex.

 

 

{!if (num_records__c >= 1 , LEFT(url__c, LEN(url__c) - 5) & "1" & RIGHT(url__c, 4), ""}
{!if (num_records__c >= 2 , LEFT(url__c, LEN(url__c) - 5) & "2" & RIGHT(url__c, 4), ""}
...
{!if (num_records__c >= 43 , LEFT(url__c, LEN(url__c) - 5) & "43" & RIGHT(url__c, 4), ""}

 

 

Not sure what you're going to do with this field, but couldn't you use a popup with a VisualForce Page / S-Control that generates this list using JavaScript?

 

gizmo100gizmo100

Thanks man!

 

I just started learning about Visualforce, and code, I will give it a try in a few weeks....Thanks!

 

by now...I got : Error: Syntax error. Missing ')' when I tried to save:

 

{!if (num_records__c >= 1 , LEFT(url__c, LEN(url__c) - 5) & "1" & RIGHT(url__c, 4), ""}

Thanks for your Help!

Gizmo

 

 

 

 

 

 

PilkoTechPilkoTech

Sorry, I didn't test this. The missing paren closes the IF statement.

 

{!if (num_records__c >= 1 , LEFT(url__c, LEN(url__c) - 5) & "1" & RIGHT(url__c, 4), "")}

 

 

gizmo100gizmo100

Thank you!!..I will need more than 100 links sometimes!! I have decided to do it in Excel by now and I will see if in a month or so I can try to create it with visualforce! Thanks for your help!! I really appreciate it.

 

Gizmo