2193
Views
19
Comments
How to convert a text to Entity identifier
Question

Hi,

I have value of type Text and I would like to convert to an Entity Identifier (Order Identifier).

How to do this?Any help appreciated?

 

Use TextToIdentifier() function


Fabian wrote:

Use TextToIdentifier() function


Hi,

Thanks for the reply.But wanted to cast to an Identifier which is of type Order Identifier where Order is an entity.

TextToIdentifier just converts in to Text Identifier not to OrderIdentifier


Cheers

RajHasti


No. TextToIdentifier converts it to a numeric identifier not a text identifier. I am assuming your order identifier is a numeric identifier. a numeric identifier is basically a long integer. 

e.g. let's say you have a text "1234" and want to store it in a variable OrderId of type Order Identifier

in your assign action you assign TextToIdentifier("1234") to OrderId


Fabian wrote:

No. TextToIdentifier converts it to a numeric identifier not a text identifier. I am assuming your order identifier is a numeric identifier. a numeric identifier is basically a long integer. 

e.g. let's say you have a text "1234" and want to store it in a variable OrderId of type Order Identifier

in your assign action you assign TextToIdentifier("1234") to OrderId


Bump,

Ran into the same issue today, TextToIdentifier just changes it to numeric, but the requirement here is to convert it into the EntityIdentifier type. Using TextToIdentifier is not solving the issue.


Anurag,


you need to convert TexttoLongInteger() or TexttoInteger() and after that LongIntegerToIdentifier() ou IntegertoIdentifier()

E.g  IntegertoIdentifier(TexttoInteger("1234")) or LongIntegertoIdentifier(TexttoLongInteger("1234"))

Use accordingly your Order Identifier ( LongInteger or Integer)


  

Fábio Fantato wrote:

Anurag,


you need to convert TexttoLongInteger() or TexttoInteger() and after that LongIntegerToIdentifier() ou IntegertoIdentifier()

E.g  IntegertoIdentifier(TexttoInteger("1234")) or LongIntegertoIdentifier(TexttoLongInteger("1234"))

Use accordingly your Order Identifier ( LongInteger or Integer)


  

Hi, I've a issue similar. I've a ID and I want to compare (with like) with a text variable.

When I try use IdentifyToText I have a warning, but if I convert first IdentifierToInteger and after IntegerToText I don't have any issue. Why Fabio? Can you explain me?

Regards,
Nuno Verdasca


mvp_badge
MVP

Hi Nuno,

What exactly are you trying to convert to what? Is the identifier an Integer, Long Integer or Text? If Integer or Long Integer, why are you trying to compare it to a Text variable?

Hi Kilian, so I understand this is an warning that is happening in version 11 and in previous ones never happened, to do the direct conversion of an Identifier to a text. The warning that appears is that like only works with two texts, and the id although it is text in the query is with identifier.

Nuno Miguel Verdasca wrote:

Hi Kilian, so I understand this is an warning that is happening in version 11 and in previous ones never happened, to do the direct conversion of an Identifier to a text. The warning that appears is that like only works with two texts, and the id although it is text in the query is with identifier.


Bump

Hi Nuno,

I'm running into the same problem. Did you ever find the answer? I'm trying to change an identifier to text. With the local variable being an entity identifier I'm trying to use IdentifierToText. As in the database the text for each identifier is active and archived that of which I need to show on screen.

mvp_badge
MVP

Hi Nuno,

Since you didn't directly answer my questions, a last attempt to get this clear: can you provide a screen shot of both the Expression and the error message, so I can see what goes on?

mvp_badge
MVP

Hi Jaret,

What is your problem exactly? Can you show what comparison you do, and what warning message you get?


Maybe I have the same problem. I am consuming REST API providing objects from external DB. object id is type of text, so when I am synchronizing data to Outsystems entities, I use Id type of text also there. For me it seems, that True change is assuming Entity id to be type of identifier. I tried several conversion functions (Like first converting textTointeger and then integer to identifier) without luck getting True change happy. (See bank account Id details in pic. There are also other similar warnings)
Code is working fine, I'd like True change to be happy without hiding warnings. How to achieve that?

TextEntityProblem.jpg

According to the documentation, TextToIdentifier should do the trick. 


mvp_badge
MVP

Hi,


Like Fábio mentioned, if you're trying to convert a Text to an Id of type Integer you need to:

  • Convert text to integer or long integer and then to identifier, so something like this IntegerToIdentifier(TextToInteger(<textValue>);

If you're trying to convert a Text to an Id of type Text you only need to apply TextToIdentifier(<textValue>).


If you do this, the warnings will go away because you're assigning integer identifiers to integer identifiers and text identifiers to text identifiers.


Cheers,

João


TextToTextIdentifier() does that exist? I can't seem to find it anywhere and Service Studio doesn't recognize it either.

mvp_badge
MVP

Tim Timperman wrote:

TextToTextIdentifier() does that exist? I can't seem to find it anywhere and Service Studio doesn't recognize it either.

 

 You are right, Tim, it is TextToIdentifier, I updated the comment. Thanks!

mvp_badge
MVP

I think TextToTextIdentifier() is what it was called pre-Platform 10. They simplified the names a bit.

Ofcourse, thanks!

I applied the recommended solution and it works, the warning disappears:

LongIntegerToIdentifier(TextToLongInteger(Text))
Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.