Skip to main content

SharePoint 2016 on-prem

 

Hello,

The SharePoint instance is on a private network so I'm not able to provide links or show screenshots.

 

A new requirement was submitted which basically sets a default value for a field (PR Asset) at item creation - by default, all items are created with '(I)' at the beginning of the item Name field: (I) example document.docx, for example.

 

At the item properties window, the user can change the default (I) setting for PR Asset to one of several other choices: (D1), (SAM), (ITOP), or (LS1T). Additionally, a Nintex Regex control strips out any spaces included by the user. At creation, the above document would appear in the library like this: (I)_example_document.docx.

 

If the user changes the PR Asset field away from the default (I), the Name field is expected to update to something like, (ITOP)_example_document.docx; however, when a new PR Asset value is chosen, the new value simply gets appended to the left of the previous value: (ITOP)_(I)_example_document.docx.

 

I need help figuring out how to strip out the (I)_ from the beginning of the item Name and replacing it with the newly chosen value; then, if a different value is chosen at any time, the workflow needs to strip out the older value and replace it with the new.

 

Any ideas? Thanks in advance.

Hi @RLNtel 



 



Your question: 



I need help figuring out how to strip out the (I)_ from the beginning of the item Name and replacing it with the newly chosen value; then, if a different value is chosen at any time, the workflow needs to strip out the older value and replace it with the new.



 



Answer



You can use Regex to replace the (I)_example_document.docx



 



The Regex



^((w*)_)(.*)



 



The Regex explanation





Group #1 is the (I)_



Group #2 is the example_document.docx



 



Regex Usage. (Using Nintex Workflow O365)





Note: Replace the "(APPLE)_" with the new Prefix e.g. "(SAM)_". Better to use variables.



 



Cheers


Thanks for the reply.



 



I tried this several times and it keeps throwing an error. Still testing. 



 



Be back soon.


1. First, hardcode the values (use the actual values, remove any variables) - does this work?



2. If it works, now replace with the variable. Log the value (Log to History).



2. Log the value of the item e.g. "(I) example document.docx" - is it really that?



3. Replace the blank spaces with underscore. Log the value.



4. Replace with the Regex I provided. Log the value - what error does it throw?



5. Share the log result.



 


Sorry for the long delay replying. Finally was able to get back to this.



 



Ok...I'm able to get hardcoded values to rotate. Fails to work with a variable as replacement text. Is it possible that the value assigned to the variable (varPRAsset:text) is failing because PR Asset is a choice field?


Since the Regex works (using hardcoded value), you need to find out why it doesn't work when using variables.



Use a Log to History action to find out what the value of the variable(s). You will need to ensure that the variables contain the correct values.



 



Show the Value before the Regex process.



Show the Value after the Regex process.



 



"Is it possible that the value assigned to the variable (varPRAsset:text) is failing because PR Asset is a choice field?" - Use the Log to display the value after it has been assign. Sometimes the mistake is due to assigning to another variable. Perhaps you are using some Logic condition but its not working as intended. 



 



 



 


Got it!



 



Also learned in the process that the Name field is was bad choice...needs, instead, to be the Title field. Reason is, if the original filename, "(I)_x.docx," gets shared and then the PR Asset gets changed, the filename changes, breaking all the shares.



 



Thanks for all your help.



 



Text editing like this needs to be done on the Title field. 



 


Reply