Add multiple values for dynamic fields using wsdl

chip's Avatar

chip

13 May, 2010 09:31 AM

Good Day,
I'm sorry if i posted this on the news page, this was an error on my part... Moved the discussion here to be more appropriate
I would just like to ask help from anyone who has tried to enter multiple values for dynamic fields?
in the definition of the dynamic fields in metadata i have already set it to accept multiple values...
My code looks like this:
$asset = array(

    'page' => array(  
        'name' => 'mytestpage',  
        'parentFolderPath' => "/testfolder/data",  
        'metadataSetPath' => "/Articles",  
        'configurationSetPath' => "/ConfigPath/Configs",
        'metadata'=>array(
            //all metadata fields are required but not all dynamic fields are required
            'title'=>'My Title',
            'displayName'=>'My displayName',
            'summary'=>'My summary',
            'teaser'=>'My Teaser',
            'keywords'=>'My Keywords',
            'author'=>'Chip Pison',
            'dynamicFields'=>array(
                //dynamic fields... arranged from required to not required
                'dynamicField'=>array(
                    //required fields
                    array(
                        'name'=>'Type',
                        'fieldValues'=>array(
                            'fieldValue'=>array(
                                'value'=>'typer'
                            )
                        )
                    ),
                    array(
                        'name'=>'Category, Main',
                        'fieldValues'=>array(
                            'fieldValue'=>array(
                                'value'=>'Valval'
                            )
                        )
                    ),
                                               array(
                        'name'=>'Other Collections',
                        'fieldValues'=>array(
                            'fieldValue'=>array(
                                'value'=>'My first val'
                            ),
                            'fieldValue'=>array(
                                'value'=>'blahblag'
                            )
                        )
                    )

When i create the asset, it gets created but it just takes the last fieldvalue in 'Other Collections'

  1. Support Staff 1 Posted by Tim on 13 May, 2010 04:40 PM

    Tim's Avatar

    This is a pretty common mistake when using PHP that I've run into myself. I believe the problem is that keys must be unique - notice that you have two 'fieldValue' keys in your last array. Try changing that part of the code to something like this:

    'fieldValues'=>array(
        array(
            'value'=>'My first val'
             ),
        array(
            'value'=>'blahblag'
             )
        )
    
  2. 2 Posted by chip on 14 May, 2010 04:11 AM

    chip's Avatar

    Hi Tim,
    thanx for the quick reply... Your solution worked fine...
    I'd also like to add that while trying all sorts of different combinations last night, i found there are other ways to place multiple values in dynamic fields.. one such combination is to use this:

                                         array(
                                'name'=>'Category, Other',
                                'fieldValues'=>array(
                                    'fieldValue'=>array(
                                        'value'=>'My first Val'
                                    )
                                )
                            ),
                            array(
                                'name'=>'Category, Other',
                                'fieldValues'=>array(
                                    'fieldValue'=>array(
                                        'value'=>'My 2nd Val'
                                    )
                                )
                            ),
    

    another way would be to use this:

                                                   array(
                                'name'=>'Category, Other',
                                'fieldValues'=>array(
                                    'fieldValue'=>array(
                                                                        array(
                                        'value'=>'first val'
                                    ),
                                                                      array(
                                        'value'=>'2nd val'
                                    ))
                                )
                            ),
    

    However, i would use ur solution in my project as it is more streamlined and easier to type... Just would like to share this to others just in case...
    Thanks again for the quick reply... I really appreciate your help...
    PS. its a good thing your support forum is really fast because i cant seem to find solutions from the kb in the site as well as proper documentation...

  3. Tim closed this discussion on 14 May, 2010 02:14 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac