Skip to main content

Hi everybody,

I have a form with a list lookup for title. But I also need the ID of the item for further workflows, because title is not unique. So I also set the option "ID connected to" to a text variable, but it gives me something like this: "86;#Title". Is there a way to get only the ID? Maybe with a regular expression?

Thanks a lot for any help.

Patrick

This should work if you just need to extract the number at the beginning of the string (i.e. it's not multiple items).

^[0-9]+


Hi Mark,

thanks for your reply. It is possible to choose multiple items. I get a string like "95;#Title1;#96;#title2". The best for me would be to have 2 collections, collection1 with the IDs and collection2 with the corresponding titles at the same position. Is there any way to accomplish this?

Thanks a lot.

Patrick


Hmmm, that's a bit trickier because the titles themselves could contain numbers, making it harder to identify them with a RegEx.

I'd try the following:

  1. RegEx to split the string by ;#. This would go into a collection variable, with the values alternating between IDs and titles.
  2. Loop through the collection, using a number variable as an index.
  3. For each item check whether the index number is odd or even (using a mod maths action).
  4. If odd, add the item to your ID collection. If even, add the item to your title collection.

I haven't tested this, but I think it would work, though there may be a more efficient method.


Hi Mark,

thanks again for your efforts. I now solved it by a workflow on item-creation that builds a string of Title_ID and following workflows compare with this definitely unique string. It's not the best way, because people now have to choose their items with that "_ID"-Suffix, but it works perfectly. Next time when i come across a similar problem, i will try your suggestion, sounds like it will work. happy.png

Cheers


Reply