Workflow run operation: results.convert-to-xls -- can you add "fields" not in results?
Hello,
I have a workflow that exports results (ie. addresses selected for mailing) to an .xls using the result.convert-to-xls operation using the following parameters:
={features:$opCreateGraphics.result, outFields: ["FULLADDRESS", "UNITTYPE", "UNIT", "ZIPCODE"], includeHeaderRow: true, sheetName: "AddressesForMailing", geometryFormat:"NONE"}
I would like to add to the xlsx conversion additional “fields” that contain static values for every record (they are not in database but would be needed for a mailout):
Example additional fields.
- [CitySt] = “Greenville, SC” (every record)
- [Recipient]= “Greenville Neighbor” (every record)
Is there a way to do this with the Operation above or otherwise simply with VertiGIS Studio Workflow?
In GeoCortex Workflow, I had to convert the existing results to a table, add fields, calculate the fields and then convert to .xlsx. I was hoping I wouldn't have to do that again. Let me know if that is really the only way.
-
Hi Carmen,
Two ideas come to mind that would save you from having to add fields and calc static values. If it's in an RDBMS, it's easier/faster probably to make a view on top of the featureclass and publish that into the webmap. Or you could try directly in workflow in javascript maybe like this :
// Assuming 'features' is your input feature set const staticValues = { CitySt: "Greenville, SC", Recipient: "Greenville Neighbor" }; features.forEach(feature => { feature.attributes.CitySt = staticValues.CitySt; feature.attributes.Recipient = staticValues.Recipient; });
//After adding the static fields to each feature, you can include these new fields in the
outFieldsparameter{ features: $opCreateGraphics.result, outFields: [ "FULLADDRESS", "UNITTYPE", "UNIT", "ZIPCODE", "CitySt", // New static field "Recipient" // New static field ], includeHeaderRow: true, sheetName: "AddressesForMailing", geometryFormat: "NONE" }
0 -
Thank you, Andy, for your suggestions and potentially a verification that I would have to add to the workflow in some manner.
In this case, I cannot make use of a RDBMS/SQL View (I have done that before in separate situations).
Thanks,
0 -
As I look closer at Andy's reply, I do not know how to “apply javascript directly in the workflow. ”. I tried to find how to do this, but I am obviously missing something. Please share any links to explain what Andy mentions.
So, to try reverting back to the original plan. I went back to the old GCE Workflow as a reference and tried to mimic the process using Studio Workflow which uses the following steps. I have run into the following questions in bold italic:
- converting the featureset to a data table using FeatureSetToDataTable Activity- Where is the equivalent activity in VertiGIS Studio? Is it present and I cannot find it? Why is there a Remove Feature Set Fields but not an Add Feature Set Fields????
- Using “Invoke Method” Activity to add the fields - Hmm. I noticed Invoke Method is a Common Server Activity in GCE Workflow. Is this possible in VertiGIS Workflow??
- cycle through records and use “Assign” activity to assign the values to the new fields -
- Run DataTableToXLS activity to export to Excel - I have this part working
Thank you for reading.
0 -
To clarify with a caveat, I'm not certain, still learning workflow myself. I've done more programming than VSW workflows, so I'm not certain we can set a variable staticValues, then reference the rows with features.forEach, or not. I don't have a working example but I will experiment with it too.
0 -
Thank you for the clarification because I sure wasn't finding a way to do what you mentioned! Yes, in theory, I know exactly what I need to do. The process works well in Geocortex Essentials workflow but I cannot find the equivalent activities in VertiGIS Workflow to end up with an .xlsx with two additional columns. It is the last item needed to finalize a long workflow to create a mailing list in excel or Avery label format of addresses meeting a bunch of criteria. So close.
I have mailing labels portion of the workflow running as expected because I could use Reporting Designer to add the Recipient and City,State to the label manually.
Have a great weekend.
0 -
Hi Carmen, I practiced with the ForEach looping through to append static values. It might work to update a collection. Here is an example making a string :
= $forEach1.item.attributes.OBJECTID + ', ' + $forEach1.item.attributes.address + ', Greenville, SC' + ', Greenville Neighbor'
0 -
You can add arbitrary fields to an esri graphic object using the Set Feature Attribute activity; the name does not need to exist yet.
So for instance, if your data comes from a Query Layer, use a For Each to loop over the resulting features, and inside that, add two Set Feature Attribute activities, one for City and one for Recipient
2 -
Thanks for that Berend. That works. Here is a simplified example workflow exported to json, adding two static fields with values into a query result. This workflow methodology absolutely takes some practice and familiarity.
0 -
Berend,
Thank you for your comment, especially the first sentence and the text I put in bold and italics below:
You can add arbitrary fields to an esri graphic object using the Set Feature Attribute activity; the name does not need to exist yet.
I would not have thought that the Set Feature Attribute activity would allow you to “create a new field” based on the VertiGIS Workflow documentation. The documentation had me to believe that the attribute had to exist before you could set a value. There is no mention that you can use this activity to “create and/or set an attribute”
So, thank you for clarifying because with your comment and suggestion, I have the export to xlsx working as I wanted to include extra static fields. Hooray!!!!!!
Carmen
0
Vous devez vous connecter pour laisser un commentaire.
Commentaires
9 commentaires