Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
protogrid:agents [2021-12-13 18:14] – [Execution] druprotogrid:agents [2023-01-16 23:16] (current) – [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 //fieldkey_parameter_value// with that key. Create a parameter Card with this Proto, copy the key of that Card and replace //cardkey_parameter_deadline_reached// with that key.
   - 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 = '3b47a5fe-894d-4580-bc0c-563aa83d9a02';+    var fieldkey_status_field = '3b47a5fe-894d-4580-bc0c-563aa83d9a02';
     var cardkey_parameter_deadline_reached = '9e13a5b0-97d5-405e-9f50-8a2f808cf541';     var cardkey_parameter_deadline_reached = '9e13a5b0-97d5-405e-9f50-8a2f808cf541';
-    var defkey_message_deadline_reached = 'a9a8143f-ad68-4df1-d57b-d8df1569c83b';+    var fieldkey_parameter_value = 'a9a8143f-ad68-4df1-d57b-d8df1569c83b';
  
     // 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 33: Line 34:
         // Here is an example for an authenticated axios GET request:         // Here is an example for an authenticated axios GET request:
         try {         try {
-            var data = await axios.get(baseurl + 'api/v2/apps/' + appname + '/cards/' + cardkey_parameter_deadline_reached, {+            var response = await axios.get(baseurl + 'api/v2/apps/' + appname + '/cards/' + cardkey_parameter_deadline_reached, {
                 'headers': {                 'headers': {
                     'Cookie': cookie                     'Cookie': cookie
Line 40: Line 41:
             console.log('axios GET request finished');             console.log('axios GET request finished');
  
-            var loaded_card = monkey_patch_card(data.result); +            var loaded_card = monkey_patch_card(response.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;
Print/export