Attribute Rule That Brings Attachments From One Table to Another

215
0
04-21-2022 01:24 PM
GdB_Admin
New Contributor III

Hello,

I am doing something a bit confusing to explain. I am creating my own Historical Table for when an inspection is done. I am doing this with the Code below. This is working exactly as planned when someone fills out the inspection in Table1 it populates my historical table (Table2). What the problem I am running into is when they fill out the inspection they are taking 12 - 16 photos each time they fill out an inspection. There is an _ATTACH table associated with BOTH tables. I want to be able to populate the _ATTACH table for Table 2 after the new record is pulled from Table1, but the GloablID (In Table2 and Table2_ATTACH) field is regenerated and then I am getting stuck on what to do next. 

What I need - An attribute Rule that will, when a new Photo is taken in Table1, Will move it to Table2 and Change the REL_GloablID field to the new GloablID that was Created in Table2. (I have a Link between Table1 and Table2 in a new GUID field called DuneGloablID in Table2) I feel like there should be a way use this field to do what I am looking for.

return {
//we want to just return the value of field `Field` no change require
"result": $feature.InspectionDate,
//this keyword indicates an edit that need to happen, its an array since we can make many edits
"edit": [
{
//the other class we want to edit
"className" : "DATABASE.DBO.TABLE2",
//the type of edit, in this case we want to add so we say `adds`, its an array since we can make many inserts
"adds" : [

{
//the attribute of the feature we want to add
"attributes":
{
"DuneGlobalID": $feature.globalid,
"InspectionDate": $feature.InspectionDate,
"Profile_Number": $feature.Profile_Number,
"Jurisdiction": $feature.Jurisdiction,
"Contract": $feature.Contract,
"Inspection_Type": $feature.Inspection_Type,
"InspectionDateOther": $feature.InspectionDateOther,
"Dune_Berm_Condition": $feature.Dune_Berm_Condition,
"Inspected_By1": $feature.Inspected_By1,
"Inspected_By2": $feature.Inspected_By2,
"Unusual_Settlement": $feature.Unusual_Settlement,
"Unusual_Settlement_Comment": $feature.Unusual_Settlement_Comment,
"Sloughing": $feature.Sloughing,
"Sloughing_Comment": $feature.Sloughing_Comment,
"Erosion_Cross_Section": $feature.Erosion_Cross_Section,
"Erosion_Cross_Section_Comment": $feature.Erosion_Cross_Section_Comment,
"Scarping": $feature.Scarping,
"Scarping_Comment": $feature.Scarping_Comment,
"Unauthorized_Excav_Vand": $feature.Unauthorized_Excav_Vand,
"Unauthorized_Excav_Vand_Comme": $feature.Unauthorized_Excav_Vand_Comme,
"Overtopping_During_High_Wat": $feature.Overtopping_During_High_Wat,
"Overtopping_During_High_Wat_C": $feature.Overtopping_During_High_Wat_C,
"Accumulation_of_D": $feature.Accumulation_of_D,
"Accumulation_of_D_Comment": $feature.Accumulation_of_D_Comment,
"Excessive_Growth_G_or_W": $feature.Excessive_Growth_G_or_W,
"Excessive_Growth_G_or_W_Comme": $feature.Excessive_Growth_G_or_W_Comme,
"Localized_Wind_Erosion": $feature.Localized_Wind_Erosion,
"Localized_Wind_Erosion_Commen": $feature.Localized_Wind_Erosion_Commen,
"Encroachment_on_Dune": $feature.Encroachment_on_Dune,
"Encroachment_on_Dune_Comment": $feature.Encroachment_on_Dune_Comment,
"Sand_Fence_Condition": $feature.Sand_Fence_Condition,
"Sand_Fence_Condition_Comment": $feature.Sand_Fence_Condition_Comment,
"Sand_Accumulation": $feature.Sand_Accumulation,
"Sand_Accumulation_Comment": $feature.Sand_Accumulation_Comment,
"Exccessive_Accumulation": $feature.Exccessive_Accumulation,
"Exccessive_Accumulation_Comme": $feature.Exccessive_Accumulation_Comme,
"Required_Maintance": $feature.Required_Maintance,
"General_Condition": $feature.General_Condition,
"Remarks": $feature.Remarks
}

}

]


}

]

}

 Thank You in advance. If you have any  questions feel free to reach out.

Thank you for your time on this. Please let me know if you have any questions
0 Kudos
0 Replies