Here an extremely simplified version of my code:
'Templates': collection ['Name'] (
'Name': text'
'File Exists': stategroup (
'Yes' {
'File': file
}
'No' { }
)
)
'File Exists': stategroup (
'Yes' {
'File': file
}
'No' { }
)
'Message': collection ['ID'] (
'ID': text
'File': file
)
Now the following action works:
'Add Message': action {
'ID': text @expected: guid
'Template': text -> ^ .'Templates'[]
'File Exists': stategroup @default: switch >'Template'.'File Exists' ( |'Yes' => 'Yes'|'No' => 'No' )
(
'Yes' { }
'No' { }
)
} as $'template' => update .'Messages' = create (
'ID' = $'template'.'ID'
'File' = switch .'File Exists'?'Yes' (
| node as $ => $ .'File'
| none => .....
)
)
However, the following code does not result in the file being added to the message collection. Can anybody help me debug? It seems that it cannot find the .‘File’ in $.
'Add Message': action {
'ID': text @expected: guid
'Template': text -> ^ .'Templates'[]
'File Exists': stategroup @default: switch >'Template'.'File Exists' ( |'Yes' => 'Yes'|'No' => 'No' )
(
'Yes' { }
'No' { }
)
} as $'template' => update .'Messages' = create (
'ID' = $'template'.'ID'
'File' = switch $'template'>'Template'.'File Exists'?'Yes' (
| node as $ => $ .'File'
| none => .....
)
)
This is the part that gives troubles: whenever ‘Yes, already included with Template’, I try to retrieve it from the template, which does not work…
As you can see, I both tried to update the status of the message with an action and ‘Set Status’ command, both result in the same.
'action': action { .... } as $'template' => switch ^ .'Messages'[ $'template'.'ID'] (
| none => update ^ .'Status' = ensure 'Failed' (
'Reason' = "Could not find Message to add Components"
)
| node as $'message' => switch $^ $'template'.'Type' (
|'Text' => execute $'message'.'Set Status' (
'Status' = create 'Sending' ( )
) //update $'message'.'Status' = ensure 'Sending' ( )
|'Document' as $ => switch $ .'Document already included?' (
|'Not yet, upload here' as $ => execute $^ $^ $'message'.'Set Status' (
'Status' = create 'Uploading Media' (
'File' = $ .'File'
)
)
// update $^ $^ $'message'.'Status' = ensure 'Uploading Media' (
// 'File' = $ .'File'
// )
|'Yes, already included with Template' => switch $^ $^ $'template'>'Template'.'Type'?'Document'.'Type'?'Static' (
| node as $ => execute $^ $^ $'message'.'Set Status' (
'Status' = create 'Uploading Media' (
'File' = $ .'File'
)
)
// update $^ $^ $'message'.'Status' = ensure 'Uploading Media' (
// 'File' = $ .'File'
// )
| none => update $^ $'message'.'Status' = ensure 'Failed' (
'Reason' = "Could not retrieve Static Document, which should be attached to the Template."
)
)
)
|'Image' as $ => switch $ .'Image already included?' (
|'Not yet, upload here' as $ => execute $^ $^ $'message'.'Set Status' (
'Status' = create 'Uploading Media' (
'File' = $ .'File'
)
)
// update $^ $^ $'message'.'Status' = ensure 'Uploading Media' (
// 'File' = $ .'File'
// )
|'Yes, already included with Template' =>switch $^ $^ $'template'>'Template'.'Type'?'Image'.'Type'?'Static' (
| node as $ => execute $^ $^ $'message'.'Set Status' (
'Status' = create 'Uploading Media' (
'File' = $ .'File'
)
)
// update $^ $^ $'message'.'Status' = ensure 'Uploading Media' (
// 'File' = $ .'File'
// )
| none => update $^ $'message'.'Status' = ensure 'Failed' (
'Reason' = "Could not retrieve Static Image, which should be attached to the Template."
)
)
)
)
)
Did you get an answer to this already, actually?