cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Brak23
Level: Power Up

Comments Over Time - Data Wiping Out

Hello,

 

I have a sharepoint list that I built a PowerApps forum around. Essentially what I am trying to do is allow users to enter comments into a Comments field and then when they click save it formats it in a field called "Comment History" as follows:

 

<User Name> - <Current Date>

<Text From Comment Field>

 

Through this forum, I was able to find a way to do it by storing the comment detail into a variable and then dropping the variable (VarCommentsHistory) and then making the Comment History item "store" that detail.

 

This works great except one fatal flaw, when users update the form and DO NOT add a comment, it will wipe all historical comments that were originally in that item. If they always add a comment each time, then it will continue to store properly. I feel like I have a logical gap somewhere in this.

 

Technical Notes:

My fields are setup as follows:

DataCardValue15 = The comments field where users enter data that should store in the history

DataCardValue8 = This is the Comments History that should be updated based on the variable

    NOTE: DataCardValue8 has its default data field = VarCommentsHistory

VarCommentsHistory = This is the variable that stores data from the username, date, and entered info into the field DataCardValue15

VarComment = This variable that helps wipe out the old data in The comments field (DataCardValue15), its the "default" for DataCardValue15 and its called in the "OnEdit" command

 

Under the "SharePointIntegration" configuration, I have setup my Advanced settings as follows:

 

OnNew:

NewForm(SharePointForm1)

 

OnEdit:

Refresh('Continuous Improvement');
Set(VarComment,"");
Set(VarCommentsHistory,"");
Set(VarCommentsHistory, SharePointIntegration.Selected.CommentHistory);
EditForm(SharePointForm1)

 

OnView:

Refresh('Continuous Improvement');
Set(VarCommentsHistory, SharePointIntegration.Selected.CommentHistory);
ViewForm(SharePointForm1)

 

OnSave:

If(
Not(IsBlank(DataCardValue15.Text)),
Set(VarCommentsHistory, User().FullName & " - " & Now() & Char(13) &DataCardValue15.Text&Char(10)&Char(10)&VarCommentsHistory),
Set(VarCommentsHistory, "")
);
SubmitForm(SharePointForm1)

 

NOTE: I think this OnSave is where my issue is, basically its to make sure that if there is info in the comments field, update the variable. But im worried that the lack of comment field and the Set(VarCommentHistory,"") is causing it to wipe out.. I basically didnt want it to post enteries in the comment history when no comments are entered. 

 

I will say that I am a total PowerApps newbie, and this is really my first form designing it to this level. Im coming from InfoPath with SharePoint. So if I missed any specific details, let me know. 

 

EDIT - 6/12/2019 

I also have tried to set the else condition on the OnSave to ensure the VarCommentsHistory is set back to the field called Comment History like so:

If(
Not(IsBlank(DataCardValue15.Text)),
Set(VarCommentsHistory, User().FullName & " - " & Now() & Char(13) &DataCardValue15.Text&Char(10)&Char(10)&VarCommentsHistory),
Set(VarCommentsHistory,SharePointIntegration.Selected.CommentHistory)
);
SubmitForm(SharePointForm1)

 

this also does not work 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Brak23
Level: Power Up

Re: Comments Over Time - Data Wiping Out

Hello,

 

I believe I have solved my issue. I noticed in looking around that people had mentioned "Append Changes to existing text must be turned off" - and both my Comments (DataCard15) and Comment History (DataCard8) were set to append changes. 

 

Also my current OnSave is now as follows - I have highlighted the changes from the initial post

If(
Not(IsBlank(DataCardValue15.Text)),
Set(VarCommentsHistory, User().FullName & " - " & Now() & Char(13) &DataCardValue15.Text&Char(10)&Char(10)&VarCommentsHistory),
Set(VarCommentsHistory,DataCardValue8.Text)
);
SubmitForm(SharePointForm1)

3 REPLIES 3
v-yutliu-msft
Level 10

Re: Comments Over Time - Data Wiping Out

Hi @Brak23 ,

Do you want that if DataCardValue15 is empty value, VarCommentsHistory will not disappear and comment history will not update?

Try to change OnSave to:

If(
      Not(IsBlank(DataCardValue15.Text)), 
      Set(VarCommentsHistory, User().FullName & " - " & 
             Now() & Char(13) &DataCardValue15.Text&Char(10)&
             Char(10)&VarCommentsHistory);SubmitForm(SharePointForm1),
       Notify("There's no data in comment field!,NotificationType.Warning)
)

 

 

 

Best regards,

Community Support Team _ Phoebe Liu

Brak23
Level: Power Up

Re: Comments Over Time - Data Wiping Out


@v-yutliu-msft wrote:

Hi @Brak23 ,

Do you want that if DataCardValue15 is empty value, VarCommentsHistory will not disappear and comment history will not update?

Try to change OnSave to:

If(
      Not(IsBlank(DataCardValue15.Text)), 
      Set(VarCommentsHistory, User().FullName & " - " & 
             Now() & Char(13) &DataCardValue15.Text&Char(10)&
             Char(10)&VarCommentsHistory);SubmitForm(SharePointForm1),
       Notify("There's no data in comment field!,NotificationType.Warning)
)

 

 

 

Best regards,

Community Support Team _ Phoebe Liu



Hey there, I tried this and still getting the same result. Anytime the comment field is blank (which there are scenarios where this should happen) shouldn't cause the history to wipe, it should just keep the history as-is. The warning pops up just fine but then when I re-open the item after saving it, the comment history is again gone. 

 

Brak23
Level: Power Up

Re: Comments Over Time - Data Wiping Out

Hello,

 

I believe I have solved my issue. I noticed in looking around that people had mentioned "Append Changes to existing text must be turned off" - and both my Comments (DataCard15) and Comment History (DataCard8) were set to append changes. 

 

Also my current OnSave is now as follows - I have highlighted the changes from the initial post

If(
Not(IsBlank(DataCardValue15.Text)),
Set(VarCommentsHistory, User().FullName & " - " & Now() & Char(13) &DataCardValue15.Text&Char(10)&Char(10)&VarCommentsHistory),
Set(VarCommentsHistory,DataCardValue8.Text)
);
SubmitForm(SharePointForm1)