Select to view content in your preferred language

Arcade Expression to reopen submitted Survey 123 surveys to edit and update.

146
1
a week ago
RachaelMurtaugh
Frequent Contributor

I have a hosted feature layer of signal light locations with a related table of inspections and maintenance. What I need to be able to do is allow the user to reopen a submitted form from Field Maps. The survey was created in Survey 123 Connect from the hosted feature layer, and currently users can click on a signal and hit a URL linked text that opens the survey with the signal's data prepopulated. 

The challenge is, I need to be able to reopen either the most recent form or be able to sort forms that have the response of either "Need minor repair" or "Needs major repair." for each signal, reopen them in Survey 123 and edit, and then resubmit them. Below is my code so far, thanks to another Community Member, but I still can't get it to work. 

When I click on the Linked Text for the Pop-up for the singal layer, it tries to open the Survey Inbox, but I get the error Code 400, Cannot perform query. Invalid query parameters. In the Survey 123 spreadsheet. I have the following in the bind::esri:parameters query="1=1&orderByFields=InspectionStartTime DESC" allowUpdates=true 

 

var urlsource = 'arcgis-survey123://?';
var inspection = FeatureSetByRelationshipName($feature, 'SignalInspection',['GUID','InspectionStartTime'], false);
var insp_count = Count(inspection);

if (insp_count==0) {
   var recmess = Text("Create New Record");
   var glid = '';
   var params = {
      itemID: 'b5ad40b0c8014d7c92715d1fb65a2de1',
      action: 'collect',
      "field:GUID": $feature["GlobalID"]
      };
return urlsource + UrlEncode(params)+ glid;

   }
else {
   for (var rec in inspection){
      var recmess = Text("Edit Existing Inspection");
      var glid = Text("&q:where=GUID=" + "%27" + $feature.GlobalID + "%27");
      var params = {
         action: 'edit',
         folder: 'inbox',
         itemID: 'b5ad40b0c8014d7c92715d1fb65a2de1',
         update: 'true',
   };
   }
}
   return urlsource + UrlEncode(params)+ glid;
   
0 Kudos
1 Reply
Neal_t_k
Frequent Contributor

@RachaelMurtaugh Instead of ordering the repeats have you tried to filter them to just "Need minor repair" or "Needs major repair."

query="Status IN ('Need minor repair','Needs major repair')

or 

query="Status = 'Need minor repair' OR Status = 'Needs major repair'"  

0 Kudos