Solved

send notification if a particular selected item is changed.

  • 12 March 2021
  • 7 replies
  • 47 views

scene:

2 lists.

List 1 is a document library.

List 2 is a list where users can choose to be alerted if one or more documents are changed in List 1.

List 2 has a lookup field, pulling the names of the List 1s documents. The user can select multiple documents.

 

If a document in List 1 is changed, and a user has it selected, the user should get a mail / alert / notification about the change.

in a workflow, attached to List 1, I make a Query.

It pulls List 2, only if the user selection is not empty.

it reads 2 fields: 

"The-Choices" which is stored in a collection variable: "Str-Choices".

and "The User" which is stored in a collection variable: "Str-Users"

 

and from here my trouble starts.

I have tried to split the Choices and users to form two variable "lists" containing each of the choices and users, as "The-Choices" in the Query contains, example: doc1.docx; picturename.jpg;calculation.xlsx  ( separated by ; )

when I make a regular expression for "The-Choices":

pattern:  ; ( a semicolon with no other chars around it )

input text: {workflowvariable:Str-Choices}

store in: EveryChoice (which is a collection variable )

 

and do the "same" with the users:

Pattern: ; ( a semicolon with no other chars around it )

input text: {workflowvariable:Str-Users}

store in: Everyuser (which is a collection variable )

 

the "send notification" mail is configured like this
TO: EveryUser

subject ( standard text about a change )

Body:

Changes made to: EveryChoice

( and some other smart infos to where and when, which works fine)

 

When changes are made, the notification mail arrives with

ALL the EveryChoice in the mail-line "Changes made to: EveryChoice"
like this: doc1.docx; picturename.jpg;calculation.xlsx

 

How do I make it send about ONLY the actually changed choices?

 

( I have not testet with multiple users, but I recon it is the same problem.. EveryUser will get a mail about EveryChoice..  😞  )

 

DO ask if there is something in the above hard to understand... I am Danish 🙂

icon

Best answer by MrCapion 3 May 2021, 15:04

View original

7 replies

Badge +7

@MrCapion 


I assume you are running the workflow for each document modified in your library, since you are using a list workflow.  Since you are dealing with a single item, I think a For Each action is more effective.  Try something like this:



 



 


 This results in a single email notification to all users tracking the file:



 



 



 


See attachment for action configurations

I assume that:


id_currID and
pg_AllUsers


are two variables ( not collection type ) ?

Badge +7

Yes, id_CurrUser and pg_AllUsers are variables.  id_CurrUser has an ID data type and pg_AllUsers has a person/group data type.


The id_CurrUser is set in the "Set str_CurrID to id_CurrID" Set Variable action (refer to the ConfigurationDetails attachment on my original post).



 

I have a strange problem.


I can not set the condition


if any value equals value


where workflow data str_Currid


 


>>> IS EMPTY


 


I only get these options:


Equal to


or


Different from


 


Did You ever see that problem?

i did a workaround on the "is empty" missing option:
leave it as a standard value field, then choose via "insert reference" > str_CurrID

now moving on to try to get it to work.

It is only sending notification to 1 user, not all.


 


this is what I have:



wait ( pause ) 1 minute. ( I have another workflow copying name to titel, and have to wait for it )


Query list:
Select only items when following is True:
List: UserSelections
Sort: TestLibrary-Choises ( a lookup field ) Contains: Titel


Field: ID saved in: TrackedFilesID ( collection type variable )



>>>>


For each:
Target: TrackedFilesID
save in: Str_CurrID ( Id type )
Index: Indexed ( numbers type )


Condition:
if one of the values is equal to the value:
value: Str_CurrID > is empty


Set Variable:
set ID_currID equal to Str_CurrID


....
Get Users:
List: UserSelections
Select only items when following is True:
show items when column:
ID ( from the list )
is equal to
ID_CurrID ( ID type variable )


Save "Username" ( from the list )
in: Pg_CurrUser ( person/group type )


....


Build string:
{WorkflowVariable:pg_AllUsers}{WorkflowVariable:pc_CurrUser}


save in: pg_allusers ( person/group type )


>>>
outside the "for each" loop:


Send notification.


to: pg_allusers 


then some text in the body..

I must "bitterly" inform You, that I dropped the extra list from wherein users could sign up to get notofications on a specific document in the other library. I thought it was smart, as it could be used "globally" to other lists and libraries. But I never could make it work, neither with Your help, nor a multiple times of trying other stuff. So I capitulated to creating a field IN the same library. A Person/Group type.


I made it work this way.
2 "extra fields" in the Library:


Users > Person / Group.


Status > Single text line.


 


Variables used:


tmp_comment / single text


NewCom / single text


UserNames / Collection


All-titles / Collection


UserColl / Collection.


 


The WorkFlow:


Wait for check out status change > wait for document is checked IN.


 


Check out item.


 


Call web service:


weburl/_vti_bin/Versions.asmx


getversions


input > item_url


output > tmp_comment


 


Query XML:


source: XML
XML > reference > {WorkflowVariable:tmp_comment}


Output 1> Xpath > //defaultNS:result/@comments


Return as: Text


Store in: NewCom


 


Set Field value:


Title = Name ( the strange sharepoint thing where uploades files has no title, only a name )



Update item:
Update: Current item


Status = editing ( pure text, to get a status for quering users/the specific item changed )


 


Commit pending changes.
As is, no changes in the function. Keep the "system generated" setting )


This is primary for the Status field update. It seems the workflow cannot set the value at this time, so


we force it to change.


 


query list:
List: My Library name is selected.
Sort: 
Users not null


Status = editing ( there You see, now ONLY the items where status is editing is found )
output fields:


users > UserNames
Title > all-titles


 


regular expression :
pattern: ; 


operation:  Split
input text: {WorkflowVariable:usernames}


store in: UserColl


 


Send Notification:
use the "UserColl" in the To: field ( send to )
use the "All-Titles" in the subject.


use any built-in reference in the "body" to make the mail make sense 😉


 


Set field value:


Status = done


 


Check in item:
Check in from: Current item
comments: {WorkflowVariable:nykom}


Check in type: No version change.


 


that's it.


Reply