Removing deleted docs from a process variable

Hi,
Do you have any idea how to remove all of the documents from a process variable that were previously physically deleted?
The deleted documents in the documents process variable (multiple) are shown as random numbers (for e.q. "85385235"...)
Please help me remove them and leave only the documents that are still valid (not deleted). Using Appian functions (not other plugins/smart services) is preferred.
Thank you in advanced...

OriginalPostID-245303

  Discussion posts and replies are publicly visible

  • @bojanb If you aren't interested in using a plugin, then I would suggest keeping the document array variable up to date as soon as soon as documents are deleted. For instance, let's say you are sending 4 documents in the document array for deletion, remove those 4 values from main document array. Or if you are deleting the entire document array, set it to null. And perform these actions either in the outputs of Delete Document or post completion of Delete Document Smart Service. An other option is to track the deleted document ids separately in a numeric array which will store ids prior to sending documents for deletion and update the main array accordingly post completion of Delete Document Smart Service. I believe there are different ways and it's your call. Let us know if you have something specific to discuss.
  • The files are written into process variable, and afterwards they can be deleted when accessed in Appian Documents tab (not in the process model). In beggining of the proces I save all the Document IDs into one variable(multiple text)...but I am a little bit stuck here...
    In one process variable (multiple - text) I have all the documents IDs (the valid ones and the ones that were deleted) and in the other process variable I have the valid documents plus those that were deleted shown with their id (this variable is multiple - type doc). Can you please help me how to get a list with the valid documents (not their ids)?
    Thank you in advance...
  • @bojanb How about applying the fn!intersection on the array 1 (that has existent and non-existent document ids) and the array 2 (that has existent document ids and the random numbers of the deleted documents)? The function output are those values that are common to both arrays which are existent document ids.

    Prior to applying the above-mentioned function, make sure that the arrays of same data type (cast the data accordingly) are sent as its arguments. Let me know if you have any follow up questions.
  • I am trying to do that - I want to make difference (fn!difference) between all the IDs (type string- they can be converted to int) and the the other variable (with the deleted IDs and the valid ones -shown as Document names - this variable is of type Document - multiple).
    If I make difference between the first array and the second, I will get an array of IDs that are valid - and afterwards I would be able to convert them into docs.
    But I can not make array 2 of type string (to contain the deleted ids and the document names of the valid docs)...
    Thank you again... If you have any idea, It would be much appreciated. BR
  • If you have 2 arrays (both of document type) where array1 contains all doc IDs (whether they were previously deleted or not) and array2 that contains ONLY deleted docs, couldn't you just do use this code?

    remove(ri!array1, wherecontains(ri!array2, ri!array1))

    You can either replace the result into array1 (if you're using it to finalize what docs should be saved) or save the result into another variable & use it for further processing.
  • I do not have the second array as deleted doc array (the deletion is done outside the process model - within appian documents). The second array contains Document names and document IDs (for the ones that are deleted). And the first array is of type text and contains all the doc ids (the deleted and the valid).
  • @bojanb May I please know the problem you are facing while opting for intersection() function as described by me earlier? I believe difference() wouldn't work here as per my analysis of your inputs.
  • Either way - I have a problem with the types of the arrays - the first one is of type Document (and contains both valid documents shown with their document names and the deleted documents shown with their document ids), and the second array is of type text...
    Thank you again for the ideas... BR
  • Then what about 1st making a conversion of the 1st array using todocument() & adding the result to another array?
  • Then the new array would be just the same as the first one (with all the docs - valid and deleted). The second one (of type text) shows the valid docs and the deleted (with their IDs). I am really stuck here...