VMware Cloud Community
segadson
Contributor
Contributor
Jump to solution

Create Properties


Hello,

I am new to java and I want to create a set of properties (name value pairs) so I can then create a soap request into vcac:  Below is my code (I also want to log and print out the set so I can see it for debugging purposes).

var propertyName = new Properties();
var propertyValue = new Properties();
var properties = {
propertyName : [
"request.callback_required",
"disk1.size_mb",
"ram.size_mb",
"eurc.lob",
"cpu.count",
"backup.required.value",
"ad.domain_name",
"app.seal_id",
"cc.cost_center",
"itsm.change_approval_group",
"itsm.change_notify_group",
"network.zone.value",
"os.version_value",
"order.behalfof_sid",
"order.creator_sid", 
"site.region",
"site.sam_id",
"sku.service_acronymn", 
"storage_type",
"tams.app_resolver", 
"tams.em_hours",
"tams.em_day",
"tams.em_time",
"tams.environment", 
"tams.maintenance_hours",
"tams.maintenance_day",
"tams.maintenance_time",
"tams.os_resolver",
"tams.site_resolver",
"tams.support_team",
"windows.auto_patch_enabled",
"windows.recovery_time_objective",
"windows.server_role"
],
propertyValue : [
request_callback_required,
disk1_size_mb,
ram_size_mb,
eurc_lob,
cpu_count,
backup_required_value,
ad_domain_name,
app_seal_id,
cc_cost_center,
itsm_change_approval_group,
itsm_change_notify_group,
network_zone_value,
os_version_value,
order_behalfof_sid,
order_creator_sid, 
site_region,
site_sam_id,
sku_service_acronymn, 
storage_type,
tams_app_resolver, 
tams_em_hours,
tams_em_day,
tams_em_time,
tams_environment, 
tams_maintenance_hours,
tams_maintenance_day,
tams_maintenance_time,
tams_os_resolver,
tams_site_resolver,
tams_support_team,
windows_auto_patch_enabled,
windows_recovery_time_objective,
windows_server_role
]
}

System.log("here are the new properties" + propertyName + " " + propertyValue);

for each (var vmProp in properties){
var propName = vmProp.get(propertyName);
var propValue = vmValue.get(propertyValue);

System.log ("found prop" + propName + " " + propValue);
}

I get the error below however:

TypeError: Cannot find function get in object

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
Burke-
VMware Employee
VMware Employee
Jump to solution

Welcome to vCO, implementing properties objects in vCO is more like this:

var props = new Properties();

props.put("myPropName", "myPropValue");

Add as many .put lines to add your various properties - the values can be objects as well as strings.

Use the API Explorer to learn more about the available properties and methods of the Properties object.

Screen Shot 2014-03-18 at 3.35.52 PM.png

To review the contents of a properties object:

for each (key in props.keys){

System.log(key +": "+props.get(key));

}

If my answer resolved or helped you, please mark it as Correct or Helpful to award points. Thank you!

Visit http://www.vcoteam.info & http://blogs.vmware.com/orchestrator
for vRealize Orchestrator tips and tutorials - @TechnicalValues on Twitter

View solution in original post

0 Kudos
4 Replies
Burke-
VMware Employee
VMware Employee
Jump to solution

Welcome to vCO, implementing properties objects in vCO is more like this:

var props = new Properties();

props.put("myPropName", "myPropValue");

Add as many .put lines to add your various properties - the values can be objects as well as strings.

Use the API Explorer to learn more about the available properties and methods of the Properties object.

Screen Shot 2014-03-18 at 3.35.52 PM.png

To review the contents of a properties object:

for each (key in props.keys){

System.log(key +": "+props.get(key));

}

If my answer resolved or helped you, please mark it as Correct or Helpful to award points. Thank you!

Visit http://www.vcoteam.info & http://blogs.vmware.com/orchestrator
for vRealize Orchestrator tips and tutorials - @TechnicalValues on Twitter
0 Kudos
tschoergez
Leadership
Leadership
Jump to solution

I am not completely sure about your syntax, but usually in JAvaScript in vCO you use

var myProps = new Properties();

myProps.put("aKeyString", aValueObject);

to "fill" the properties, and

for each (var key in myProps.keys) {

var currentValue = myProps.get(key);

}

Cheers,

Joerg

Edit: damn, once again too late 🙂 Not my day today. Anyway, found a error in my original code, corrected in place now (the method is called put(key, value)..... )

segadson
Contributor
Contributor
Jump to solution

cool thank you!

0 Kudos
segadson
Contributor
Contributor
Jump to solution

Thank you as well! yea I was able to get it to work now Smiley Happy

0 Kudos