I have a lot of occasions where I want to patch a single line of text with a combination of an ID column to generate some Service Code. I was hoping to use a simple Concatenate.
[Text-]-[Text-][ID]
I'm able to convert numbers to Text using Value()
Exactly, I love how these forms are setup with this OnSubmit and like.
If the ID is auto-generated when you create a new element in the NewForm(...), you should be able to get it on the OnSuccess action of the form, by looking at the LastSubmit property of the form - it contains the item that was created after submitting the form. From its description:
LastSubmit – The last successfully submitted record, including any server generated fields.
Thanks Carlos, I tried that but initally encountered expectations of placeholders, as in Text Date syntax.
The context is as follows.
Example service code
SC-KBCE-ABA-66
[SC-][CompanyABBR-][ServiceType-]-[ID]
The method I added a Confirm Save step with a button so I could get the ID from the SharePoint list visible in a Text field. Then I would patch, if confirmed. WORKS
Patch('Service Code',GalleryServiceCodes.Selected,{Title:Concatenate("SC-",LookUp(RegisteredClientsCollection,Company=DataCardValue7.Selected.Value,ShortCode),"-",LookUp(ServiceTypesCollection,DataCardValue75.Selected.Value=Title,ShortCode),"-", DataCardValue29.Text)});UpdateContext({ServiceCodesDisplayFormVisible:false,ServiceCodesGalleryVisible:true,ServiceCodesEditFormVisible:false,ServiceCodesSaveConfirmationVisible:false,NewServiceCode:false});ClearCollect(ServiceCodesCollection,'Service Code')
My actual wish was to patch on the first save, but Text(ID) on its own isn't recognised.
Patch('Service Code',GalleryServiceCodes.Selected,{Title:Concatenate("SC-",LookUp(RegisteredClientsCollection,Company=DataCardValue7.Selected.Value,ShortCode),"-",LookUp(ServiceTypesCollection,DataCardValue75.Selected.Value=Title,ShortCode),"-", Text(ID))});UpdateContext({ServiceCodesDisplayFormVisible:false,ServiceCodesGalleryVisible:true,ServiceCodesEditFormVisible:false,ServiceCodesSaveConfirmationVisible:false,NewServiceCode:false});ClearCollect(ServiceCodesCollection,'Service Code')
I tried to add specificity, but was wondering as Patch already was specific about which record I'm refering to in 'GalleryServiceCodes.Selected'. My new more specific code does work, but only on confirmation step, not in one step as in a New Form.
Patch('Service Code',GalleryServiceCodes.Selected,{Title:Concatenate("SC-",LookUp(RegisteredClientsCollection,Company=DataCardValue7.Selected.Value,ShortCode),"-",LookUp(ServiceTypesCollection,DataCardValue75.Selected.Value=Title,ShortCode),"-", ID)});UpdateContext({ServiceCodesDisplayFormVisible:false,ServiceCodesGalleryVisible:true,ServiceCodesEditFormVisible:false,ServiceCodesSaveConfirmationVisible:false,NewServiceCode:false});ClearCollect(ServiceCodesCollection,'Service Code')
The function Value converts from text to numbers; you need to use the Text function instead. With that, you should be able to use the Concatenate function to do your concatenation:
Concatenate("text1", "-", "text2", "-", Text(234))
WarrenBelz
146,651
Most Valuable Professional
RandyHayes
76,287
Super User 2024 Season 1
Pstork1
65,999
Most Valuable Professional