Refreshing a Grid from two different scenarios

I have an interface that gets data via an integration and then filters those results:

  local!caseCommentsResult: rule!UWM_Get_Case_Comments(caseId: ri!caseId),
  local!caseComments: local!caseCommentsResult.result.body,
  local!filteredActivities: a!forEach(
    items: local!caseComments,
    expression: if(
      tostring(fv!item.commentType) = "CASE_NOTE",
      fv!item,
      null
    )
  ),

And it is displayed in a grid:

a!columnLayout(
        contents: {
          a!localVariables(
            local!pageSize: 25,
            {
              a!gridField_23r3(
                emptyGridMessage: "No comments available",
                data: local!filteredNonNullActivities,


I want the grid to refresh on two different scenarios - 
1.  on RECORD_ACTION  (adding a new row)
2.  when a row is edited by direct integration call

I've tried various different scenarios of local variables but cannot figure out how to get the refresh to work with both these scenarios, especially since something like this

local!isCommentAdded: a!refreshVariable(
value: true,
refreshAfter: "RECORD_ACTION"
),

Always sets the value to true, there is no actual change in value of that variable to work with.

Here is my best attempt -

  local!editCompleted : false,
  local!isCommentUpdated: a!refreshVariable(
    value: local!editCompleted,
    refreshOnReferencedVarChange: local!editCompleted
  ),
  local!isCommentAdded: a!refreshVariable(
    value: true,
    refreshAfter: "RECORD_ACTION"
  ),
  local!isRefreshNeeded: if(
    or(
      local!isCommentUpdated,
      local!isCommentAdded
    ),
    true,
    false
  ),
  
    local!caseCommentsResult: a!refreshVariable(
    value: rule!UWM_Get_Case_Comments(caseId: ri!caseId),
    refreshOnReferencedVarChange: local!isRefreshNeeded
  ),



But because "isCommentAdded" is always true there is no change for caseCommentsResult to act upon.


  Discussion posts and replies are publicly visible

Parents Reply
  • 0
    Certified Lead Developer
    in reply to nancyb0004

    In rarer cases like this, I've found it useful to use a local timetamp.

    local!lastUpdateTime: a!refreshVariable(value: now(), refreshAfter: "RECORD_ACTION"),

    this value will be updated to a new timestamp any time a record action is observed.  This variable cand then be added to the refresh variable "on var change" watchers for any relevant local variable(s) that need to be updated after the record action.

Children
  • TY - so my test is would then be?   Currently looking for 

     local!isCommentUpdated: a!refreshVariable(
        value: local!editCompleted,
        refreshOnReferencedVarChange: local!editCompleted
      ),
      local!isCommentAdded: a!refreshVariable(
        value: now(),
        refreshAfter: "RECORD_ACTION"
      ),
      local!isRefreshNeeded: if(
        or(
          local!isCommentUpdated,
          local!isCommentAdded
        ),
        true,
        false
      ),


    How do I compare the value now of isCommentAdded in the isRefreshNeeded block?