Versions Compared

Key

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

...

return statements are optional but it makes script more readable.

Get Asset's Attribute value

Code Block
return aipUtils.getAttributeValueAsStringByName(asset, 'Quantity');

Result: 40


Get Asset's Multiple Value Attribute values by name as List

Code Block
import inventoryplugin.entity.JipInventoryItem;
import org.apache.commons.lang3.StringUtils;

String getMultipleValues() {
    def result = '';
    def cityList = aipUtils.getMultiAttributeValueAsListByName(asset, 'Cities ListBox Multiple');
  	for (String city : cityList) {
      result += city + ', '
    }
    return result;
}
return getMultipleValues();
Result: New York, London,



Get Asset's Multiple Value Attribute values by ID as List

Code Block
import inventoryplugin.entity.JipInventoryItem;
import org.apache.commons.lang3.StringUtils;

String getMultipleValues() {
    def result = '';
    def cityList = aipUtils.getMultiAttributeValueAsListById(asset, 63);
  	for (String city : cityList) {
      result += city + ', '
    }
    return result;
}

return getMultipleValues();

Result: New York, London,


Get Asset's Attribute values by asset object in a loop

Script:

Code Block
import inventoryplugin.entity.JipInventory
import inventoryplugin.entity.JipInventoryItem

def result = ""
result = result + "\n" + "Asset name: " + asset.getName()
result = result + "\n" + "Form name: " + asset.getForm().getFormName()
result = result + "\n" + "Attachments details: " + asset.getAttachments()
result = result + "\n" + "Creator: " + asset.getCreator()
result = result + "\n" + "Create time: " + asset.getCreated()

// attributes of asset
for(JipInventoryItem inventoryItem: asset.getInventoryItems()){
  // For the demo, we append all values to the Text area, so we skip TextArea attribute type values.
  if(inventoryItem.getFormAttribute().getAttribute().getAttributeType() != 'TextArea'){
    result = result + "\n" + inventoryItem.getFormAttribute().getAttribute().getAttributeName() + 
      ": " + inventoryItem.getValue()
  }
}

return issue.description + "\n" + result

...