How to create a Folder in SFTP and then push all the documents in this SFTP folder that are in the folderID location in Appian.

Certified Associate Developer

Hi All, 

I have a use case as below:

Appian case documents push to SFTP:

  1. Fetch all the relevant caseIds and its appian folder ids that are stored in the database.
  2. For each case create a folder in SFTP server as clientname_caseID format.
  3. Then push all the documents in this folder that are in the folderID location in Appian.
  4. Update status for doc_sent = 1 if SFTP status is success so this case doesn't get picked up again. 
  5. Continue this process for the cases.

Please advise how do I write a Query rule to fetch case Id and folder id from database and pass this to a process model that would call the SFTP Smart Service. Do I need to use both "SFTP Create Folder" & "SFTP Send File" smart services for this use case.  

Below is the query rule I've written to fetch the case Ids and folder Ids from database. How do I map this to a process Model?


a!queryEntity_22r2(
entity: cons!ABC_CASES,
query: a!query(
pagingInfo: a!pagingInfo(
startIndex: 1,
batchSize: -1,
)
),
selection: a!querySelection(
columns: {
a!queryColumn(field: "caseId"),
a!queryColumn(field: "folderId")
}
),
logicalExpression: a!queryLogicalExpression(
operator: "AND",
filters: {
a!queryFilter(
field: "caseId",
operator: "=",
value: ri!abc_cases.caseId,
applyWhen: not(
rule!APN_isBlank(ri!abc_cases.caseId)
)
),

)
}
)
)
)

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer

    In the query rule you should add a filter for  doc_sent <> 1. So that the rule returns all the cases whose document is not sent already. 
    Apart from this call the rule in the process model script task and store in the a pv. the pv should be of the same data type as the output returned by the rule. 

  • 0
    Certified Associate Developer
    in reply to Harsha Sharma

    Thanks for the response  . And once I call this rule in the process model script task, how do I fetch the folder Id based on one case per run to pass it further to SFTP folder ?

  • 0
    Certified Lead Developer
    in reply to manam

    your output is having folder id and case id both right.You can use index() to extract the folder if and case id. 

    In your main process model call this rule and get the list of cases. then call a sub process (or start process smart service) using MNI. within this sub process you will be having one case and one folder at a time. within this sub process have the sftp smart service to send document for one case. Like wise depending on the number of cases that many sub process instances will trigger and docs will be transferred. 

    In above rule you have paging done as -1. See MNI usage considerations to verify if your output can reach the maximum activity instances limit permitted or else adjust the paging using loops in process model to get cases and folders in batches.

Reply
  • 0
    Certified Lead Developer
    in reply to manam

    your output is having folder id and case id both right.You can use index() to extract the folder if and case id. 

    In your main process model call this rule and get the list of cases. then call a sub process (or start process smart service) using MNI. within this sub process you will be having one case and one folder at a time. within this sub process have the sftp smart service to send document for one case. Like wise depending on the number of cases that many sub process instances will trigger and docs will be transferred. 

    In above rule you have paging done as -1. See MNI usage considerations to verify if your output can reach the maximum activity instances limit permitted or else adjust the paging using loops in process model to get cases and folders in batches.

Children
No Data