Question on ID of Entitiy

Question on ID of Entitiy

  
1. Can I start an ID of an Entity at a specific number (ro example...20000)?
2. Can I search on Entity ID?
select * from customers where customer.id like <searchfield>?

Hi Aron,

1) Yes you can change the starting ID of your entity, but the way to do it is either thru configuring the setting of your ID in the  design of your table using SQL Server manually or Executing an SQL script.
ALTER SEQUENCE example_id_seq START 1000

2) Yes, by using Advance Query but try to use {customer}.* in your query.

Hope this helps,
Mark Chua
Hi Aron, Mark,

I just wanted to add that you can do that with a simple query as well, which is the preferred way, since it will be optimized by the platform to get only the columns you actually use in your code.

Cheers,
Daniel
Thanks all.
In a simple query, how can I get a search input to search 'customername' and customer_id?  the search input in text and the id is int...so when you put in "1"...it returns no results.
I don't think I can modify the Query to use CAST, etc.

Hi Aron,

That sounds like a strange requirement, since name and Id are unrelated. Why do you need to use the same search term on both?

Regardless, you can have 2 search parameters in your simple query, one Text and another of your Entity Reference type (or Integer, but you lose the platform's type checking), and then pass in the same variable for both parameters, applying any conversion you need there (for instance text to integer).

Cheers,
Daniel


OK...thanks.  Let me back up to see the best way to do this.
1. I need an Airbill ID
2. It must be a unique. (But typing in the field should be permitted is OK but not needed).  My thought is to make it the same as the ID on SAVE.
3. if field is empty, it should autogenerate a unique number (thus the ID would work here)
4. I need to be able to search on this field.  Not a big deal if this is text. (if it is an ID as noted above, i can't seem to make searching for text and the ID work from the same search field.
Hi Aron,

If you need a user customizable Id, you cannot use an auto number. I would advise having an auto number Id (the one the platform automatically generates for you), and a separate identification code or number the user may alter (in which case you also need to create an action to populate it when the user doesn't supply one). When you need to search on the attribute, be sure to add an index to the table, so that when the table grows large, a query on the attribute still performs.

Best regards,


Kilian
OK...I appreciate all the help and like to follow up with the solution that I came up with to close things out.
1. I will use the standard ID in the table, but went to SQL studio directly and used the RESEED command.  This allowed me to start the ID in the range I wanted.
2. I decided to really understand "why" we needed to have this field customized (allow inputs to) and decided to put this as a separate entry in the database
3. For my search, I used the integerToText() function for the ID...works great.  Now once search field can search across many database fields instead of having multiple search boxes.
Thanks again for everyones help and I am sure I will become more involved here.  This is only my third week with this app...

Hi Aron,

I've attached an espace with examples of how I would approach this. There's two pages, Test1 and Test2.
Test1 solves a problem like your ID problem, while Test2 searches for the same term in two fields of an entity, using a simple query.

I hope this helps.. For me it's easier to share this than try to describe everything in text :)
Let me know if you have any questions about what's in there.

Cheers,
Daniel
Make sure you go into the Entity's "More Properties" and set a manual index on that text field if you plan to do a lot of searching on it, and consider setting a "Unique" constraint too if that makes sense.

J.Ja