VMware Cloud Community
SatishPatil
Enthusiast
Enthusiast
Jump to solution

DynamcTypes -- Dependency

Hi All,

I have two input parameters datacenter and freeblades. Both are dynamic datatypes. The user selects the datacenter first and then the freeblades. Freeblades should show only freeblades in the chosen datacenter. When the freeblades is choosen in the "Chooser" findAll method of freeblades gets involved. How to access the value of datacenter in findAll method of freeblades to filter only blades for that datacenter.

Any help appreciated.

Reply
0 Kudos
1 Solution

Accepted Solutions
iiliev
VMware Employee
VMware Employee
Jump to solution

I'd suggest to use 'predefined' functionality for this.

Add 'Predefined list of elements' property in the presentation for the freeblades property and bind it to a scripting action that accepts as an input a datacenter object and returns an array of freblades. Inside this action, return an array of freeblades objects that belong to this datacenter.

View solution in original post

Reply
0 Kudos
13 Replies
iiliev
VMware Employee
VMware Employee
Jump to solution

I'd suggest to use 'predefined' functionality for this.

Add 'Predefined list of elements' property in the presentation for the freeblades property and bind it to a scripting action that accepts as an input a datacenter object and returns an array of freblades. Inside this action, return an array of freeblades objects that belong to this datacenter.

Reply
0 Kudos
SatishPatil
Enthusiast
Enthusiast
Jump to solution

I made datacenter as dynamic datatype so that it goes through chooser popup and dependent parameter i.e. freeblades) as string. The issue is in data binding for freeblades parameter lookup , datacenter parameter does not show up. It looks like only parameters of type string are displyed. I added #datacenter in data binding even though it does not show up in the popup. After selecting the datacenter, free blades has "ch.dunes.model.type.NotFoundObject@4ba240". As per the following error it is able to find action getAllFreeBladesProperties 

2014-11-27 13:40:45.766-0600 [http-bio-10.100.240.35-8281-exec-2015] WARN  {} [S

criptProperty] Cannot find a type for attribute: vCenter, value: DynamicObjectPr

oxy [dynObject=null, type=DynamicTypes:org.vDataCenter, id=npc1uv00vvc]

2014-11-27 13:40:45.766-0600 [http-bio-10.100.240.35-8281-exec-2015] WARN  {} [S

criptModuleRuntimeServiceImpl] Unable to execute action class java.lang.NullPoin

terException: type Cannot be null

2014-11-27 13:40:45.766-0600 [http-bio-10.100.240.35-8281-exec-2015] ERROR {} [V

coFactoryServiceFacadeProxy] ch.dunes.util.DunesServerException: Action 'getAllF

reeBladeProperties' in module 'com.org.dynamicTypes' failed : type Cannot b

e null

Reply
0 Kudos
iiliev
VMware Employee
VMware Employee
Jump to solution

Hmm, these 'type cannot be null' errors look like a bug. I'll take a look at it when I have time (hopefully next week).

As a workaround, you can try to bind the action input parameter not to the whole object (#datacenter) but only to its id which is a plain string (if needed, later inside your action you can retrieve the whole object by its id). So your binding expression may look like the following:

GetAction("com.org.dynamicTypes","getAllFreeBladeProperties").call( (#datacenter == null) ? null : #datacenter.id )

Reply
0 Kudos
SatishPatil
Enthusiast
Enthusiast
Jump to solution

As soon as pop up comes up to get parameters it throws the following errors. The freeBlades calls GetAction("com.org.dynamicTypes","getAllFreeBladeProperties").call( (#datacenter == null) ? null : #datacenter.id )

2014-11-28 10:59:41.944-0600 [http-bio-10.125.240.35-8281-exec-2142] ERROR {} [V

coFactoryServiceFacadeProxy] ch.dunes.util.DunesServerException: Action 'getAllF

reeBladeProperties' in module 'com.cas.dynamicTypes' failed : ReferenceErro

r: "Sysetm" is not defined. (unnamed script#2)

Reply
0 Kudos
iiliev
VMware Employee
VMware Employee
Jump to solution

Seems that you have a typo in the action's scripting code (on line 2).

Do you have a call to some method on system scripting object on this line? If yes, It should be "System" not "Sysetm"

Reply
0 Kudos
SatishPatil
Enthusiast
Enthusiast
Jump to solution

Ignore the above message.. misspelled System.

Reply
0 Kudos
SatishPatil
Enthusiast
Enthusiast
Jump to solution

After creating dependency between fields, the log shows actions are called two times.

The following is workflow input parameter Presentation configuration

datacenter:

               datatype : Dynamic

               Presentation properties: Mandatory

freeBlades:

               datatype : String

               Presentation properties: Predefined List of Elements: GetAction("com.cas.dynamicTypes","getAllFreeBladeProperties").call( (#datacenter==null)?null:#datacenter.id)

                                                  Data Binding : #datacenter

After datatype is choosen from the popup, findById is triggered on datacenter then getAllFreeBladeProperties and same actions get called again right away i.e findById gets triggered then getAllFreeBladeProperties.

Any help appreciated.

Reply
0 Kudos
iiliev
VMware Employee
VMware Employee
Jump to solution

I was thinking more about the following input parameter configuration:

Workflow/presentation

    datacenter:

        type: dynamic_datacenter_type

        properties: mandatory

    freeBlades:

        type: Array/dynamic_freeblade_type

        properties: predefined list of elements: GetAction("com.cas.dynamicTypes","getAllFreeBlades".call( (#datacenter==null)?null:#datacenter.id )

    (note1: there is no property 'data binding'

     note2: the type of freeBlades input above is an array, assuming your workflow accepts more than one free blade per datacenter. If you need only one free blade per datacenter, change the type to a single non-array)

Action  getAllFreeBlades

    input argument name: datacenterId  

    input argument type: string

    return type:  Array/dynamic_freeblade_type

action script code may look something like:

if (datacenterId == null) {

  return []; // no datacenter object provided -> no free blades returned

}

// compute which freeblades belong to the datacenter with id = datacenterId

// let's suppose there are 2 freeblades with ids 'fb-id-1' and 'fb-id-2'

var fb1 = DynamicTypesManager.getObject("my_dynamic_namespace", "dynamic_freeblade_type", "fb-id-1");

var fb2 = DynamicTypesManager.getObject("my_dynamic_namespace", "dynamic_freeblade_type", "fb-id-2");

return [fb1, fb2];

in the code above, your dynamic types are named 'dynamic_datacenter_type' and 'dynamic_freeblade_type' and are defined in a namespace 'my_dynamic_namespace'

Reply
0 Kudos
SatishPatil
Enthusiast
Enthusiast
Jump to solution

I changed as per your suggestions above and now action getAllFreeBlades does not get triggered.

I used getObject in findbyId it went into endless loop. When to use makeObject and when getObject.

Reply
0 Kudos
iiliev
VMware Employee
VMware Employee
Jump to solution

makeObject() should be used only in 'finder' workflows which you bind to when defining the dynamic type - findById, findAll, findRelation and hasChildrenInRelation.

In all other workflows you should use getObject()

Reply
0 Kudos
SatishPatil
Enthusiast
Enthusiast
Jump to solution

Thanks llian,

Any idea why action does not get called after datacenter is called. I was hoping to see findById and then followed by getFreeBlades method being called.

Reply
0 Kudos
iiliev
VMware Employee
VMware Employee
Jump to solution

Not sure. Are there any errors/warnings in the logs? Which vCO version/build do you use?

I'm not in the office right now but tomorrow I'll try to reproduce it in my environment.

Reply
0 Kudos
SatishPatil
Enthusiast
Enthusiast
Jump to solution

No errors. I am using vco 5.5.1.

I created the sample described in the blog https://urldefense.proofpoint.com/v2/url?u=http-3A__mighty-2Dvirtualization.blogspot.com_2010_10_vco...=

String datatype

The following is my observation

     Input1: datatype: String

          Properties:Mandatory

     Input2: dataType:String

          Properties: Predefined List. GetAction...

     In this case value of input2 changes  according to Input 1 selection.

     Input1: datatype: String

          Properties:Mandatory

     Input2: dataType:Array/String

          Properties: Predefined List. GetAction....

                           Databinding #input1

     Need to add databinding to make it work.

Dynamic DataType

     datacenter:DataType: DyanmicTypes.CAS.datacenter

          Properties:Mandatory

     freeBlade:DataType: DyanmicTypes.CAS.freeBlade

          Properties:PredefinedList. GetAction .....

findById gets triggered but getAction for freeBlade is not triggered

Reply
0 Kudos