Post

5 followers Follow
0
Avatar

Auto-increment ID with an initial value.

One of our companies uses an important auto-increment value to classify Sales Opportunities. I would like to import these opportunities into podio.

The Podio Unique ID field would be ideal. But my field's has an initial value of 20 000.

If I want these people to use Podio, they need to see the number they always used for their archives.

I'm looking into two separate solutions :

  1. Adding 20,000 to Podio's Unique ID

    I have tried but failed. It is put together as strings.
    Is there a formula to add to the unique ID as an Integer?

  2. Importing 20000 empty lines and then delete them.

    This seems extreme to me.

Maybe someone can help me?

David Gélinas

Please sign in to leave a comment.

12 comments

0
Avatar

Hi David,
Have you tried to use a calculation field with this Formula :


var initial = 20000;
@UniqueId + initial

\Hamid

Hamid 0 votes
0
Avatar

This again gives me a concatenated value => 120000. Which is the ID of the first item joined with 20000.
I need the first item to have the value of 20001 then 20002 and so on.

Does that give you a hint for an solution?
Thanks for answering Hamid.

David Gélinas 0 votes
0
Avatar

Hi David,

the unique ID is a string with a standard prefix "INV-". You have to replace the prefix first and then convert it to a number:

var a = @UniqueID.replace(/INV-/, "");
+a + 20000

// result: 20,001 for the first item

Rainer
rg@delos-consulting.com

Rainer Grabowski (FVM) 0 votes
0
Avatar

The Rainer's code is good and give you a number field on witch you can apply a filter. But if you want a text field
modify my first contribution like this :


var initial = 20000;
parseInt(@UniqueId, 10) + initial + ' '

Put your calculation field at the top of the app to have a possibility to make a search on it in the search bar
:)

Hamid 0 votes
0
Avatar

Hi there,
I know this question was quite a while ago now but I'm trying to do a similar thing and wondered if you could help.

I'm making an invoice app and need the Unique ID to start at 2517 (it's currently at 42) and every time I add a new item (invoice) it goes up incrementally by 1 so the next number is 2518.

I've tried the code you have both suggested and yours Rainer works but gives me 2518.0 (which I could live with even though I'd love to get rid of the '.0') but when I try and save the modification it says "The type of result changed from text to number" and won't let me save it.

Can you help?

Rachel Gretton 0 votes
1
Avatar

Hi Rachel,

I assume you've had only @Unique ID in the field when you've saved it the first time. Unique ID is a (text) string and the calculation has been saved as a text type field. The result of my calculation example is a number. You can use a modification of Hamid's code which gives back a string:

(parseInt(@Unique ID,10) + 2475).toString() 

.toString() does the same as the quoation marks in Hamid's code.

Rainer

Rainer Grabowski 1 vote
0
Avatar

Thanks Rainer! That works.
I don't suppose there is a bit of code that will make the result '2475' rather than '2,475.00' is there?

Rachel Gretton 0 votes
0
Avatar

Hi Rachel,

(parseInt(@Unique ID,10) + 2475).toString() .replace(/\B(?=(\d{3})+(?!\d))/g, ",")

Result: 2,517 (if ID = 42 as you mentioned in your first posting)

 (parseInt(@Unique ID,10) + 2475).toFixed(2).replace(/(\d)(?=(\d{3})+\.)/g, '$1,') 

Result: 2,517.00

Rainer
rg@delos-consulting.com

Rainer Grabowski 0 votes
0
Avatar

Thanks again Rainer. So there's no way to get rid of the comma after the 2 then? I realise it isn't a equation and is purely just for the look of the invoices but I just wondered if it was possible.

Rachel Gretton 0 votes
0
Avatar

Hi Rachel,
This is my code witch i use for Quotation id's
perhaps this will help you and others.
I use tow parts in my case : month and year + an incrementing number


Hamid 0 votes
0
Avatar

Hi Rachel,

sorry, I've thought you wanted a comma. But you want a number without comma and without decimals - right? This one I've posted yesterday should be without a comma and without decimals.

    (parseInt(@Unique ID,10) + 2475).toString() 

If not, please copy and paste your original code here.

Rainer

Rainer Grabowski 0 votes