Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Groovy examples for Asset Attribute Types

Attribute TypeGroovy exampleNotes
CheckboxList
return "ist"
For now only one value is supported and current value will be lost.

DatePicker

import java.time.*  
  LocalDateTime t = LocalDateTime.now();  
  return (t as String) 
Result must be in ISO format ("yyyy-MM-dd"), i.e: "2018-12-26"
DateTimePicker
import java.time.*  
  LocalDateTime t = LocalDateTime.now();
  return (t as String) 
Result must be in ISO format ("yyyy-MM-ddTHH:mm"), i.e: "2018-12-26T20:20". You do not need to do formatting if you use LocalDateTime class as it returns in ISO format by default.
DropdownList
return "ada"
Return a valid option value.
InventoryList
return "3"
Return reference asset ID
InventoryListByForm
return "10"
Return reference asset ID
IP
return  "10.0.0.2"
Any text is possible, there is no format control.
IPv6
return "2001:0db8:85a3:0000:0000:8a2e:0370:7334"
Any text is possible, there is no format control.
ListBox
return "izm"
Return a valid option value.
ListBoxMultiple
return "ada"
Return a valid option value. For now only one value is supported and current value will be lost.
RadioButtonList
return "ist"
Return a valid option value.
Text
return issue.summary
Any text is possible.
TextArea
return issue.description
Any text is possible.
URL
return "http://www.snapbytes.com/"
Any text is possible, there is no format control.
UserPicker
return issue.reporter.username
Any text is possible, there is no control. You may use issue.reporter.username or issue.assignee.username

 

 

Another post function example for All Attribute types

You can update all fields of an attribute in one post function.

Image Added