Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionLast revisionBoth sides next revision | ||
protogrid:agents [2021-12-13 17:32] – [Agents] dru | protogrid:agents [2021-12-13 18:20] – [Example] dru | ||
---|---|---|---|
Line 9: | Line 9: | ||
==== Example ==== | ==== Example ==== | ||
- Create a Proto with a DateTime Field and a Text Field. Copy the key of the Text Field. | - Create a Proto with a DateTime Field and a Text Field. Copy the key of the Text Field. | ||
- | - Create a user profile with rights to edit the proto created above. | + | - Create a user profile with rights to edit the proto created above but without Environment Administrator rights. |
- | - Create an Agent Library, specify the user created above as context user and copy the following code. Replace the value of //defkey_status_field// with the key from above. | + | - Create an Agent Library, specify the user created above as context user and copy the following code. Replace the value of //fieldkey_status_field// with the key from above. |
+ | - Create a Proto for parameter values with a Text Field, copy the key of the Text Field and replace // | ||
- Add this Agent Library to your Proto. | - Add this Agent Library to your Proto. | ||
- Based on this proto, create some cards where the date lies within the next 60 minutes. Wait one hour. | - Based on this proto, create some cards where the date lies within the next 60 minutes. Wait one hour. | ||
Line 17: | Line 18: | ||
<code javascript> | <code javascript> | ||
function agent_library() { | function agent_library() { | ||
- | var defkey_status_field | + | var fieldkey_status_field |
var cardkey_parameter_deadline_reached = ' | var cardkey_parameter_deadline_reached = ' | ||
- | var defkey_message_deadline_reached | + | var fieldkey_parameter_value |
// Make sure that this function does not return until all operations and JSON-API requests are completed / fulfilled. | // Make sure that this function does not return until all operations and JSON-API requests are completed / fulfilled. | ||
Line 41: | Line 42: | ||
var loaded_card = monkey_patch_card(data.result); | var loaded_card = monkey_patch_card(data.result); | ||
- | var loaded_message = loaded_card.get_value(defkey_message_deadline_reached, 'Frist abgelaufen' | + | var loaded_message = loaded_card.get_value(fieldkey_parameter_value, 'Frist abgelaufen' |
- | card.set_element_value(defkey_status_field, loaded_message); | + | card.set_element_value(fieldkey_status_field, loaded_message); |
return true; | return true; | ||
Line 59: | Line 60: | ||
===== Execution ====== | ===== Execution ====== | ||
- | Agents are by default checked every hour (this can be modified for your environment, | + | Agents are by default checked every hour (this can be modified for your environment, |
+ | |||
+ | Agents run in the context of a specific user profile | ||
While an agent is running in the context of a specific card, it is also possible to load and save other cards by calling the JSON API endpoints using axios. A valid axios module is given in the // | While an agent is running in the context of a specific card, it is also possible to load and save other cards by calling the JSON API endpoints using axios. A valid axios module is given in the // |