Announcement

Collapse
No announcement yet.

array_insert issue

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • K Series Parts
    replied
    Originally posted by Scot - ScotsScripts.com View Post
    Look at the mvforeach. I put l.disco and l.discos and you had disco and discos
    Thanks again, testing does appear to have it on track now!

    Leave a comment:


  • K Series Parts
    replied
    Originally posted by Scot - ScotsScripts.com View Post
    Look at the mvforeach. I put l.disco and l.discos and you had disco and discos
    Thanks! That seems to have cleared it up and doing more testing on it now.

    Leave a comment:


  • dcarver
    replied
    My quick test using your original code output the values as expected. I'd double check what's actually being returned from your custom field call.
    Code:
    <MvASSIGN NAME = "l.discos" VALUE = "{ miva_array_deserialize( '[1]=A,[2]=B,[3]=C' ) }" />
    
    <MvFOREACH ITERATOR = "disco" ARRAY = "discos">
        <MvASSIGN NAME = "l.ok" VALUE = "{ miva_array_insert( l.disco_list, l.disco, -1 ) }" />
    </MvFOREACH>
    
    <MvEVAL EXPR = "{ l.disco_list }">
    output
    Code:
    A,B,C

    Leave a comment:


  • Scot - ScotsScripts.com
    replied
    Look at the mvforeach. I put l.disco and l.discos and you had disco and discos

    Leave a comment:


  • K Series Parts
    replied
    looks the same, am I missing something?

    Leave a comment:


  • Scot - ScotsScripts.com
    replied

    Ok, I just noticed you're not scoping your variables. When using miva script you have to scope variables, it's not like mvt code. Try this:
    Code:
      
    <MvFOREACH ITERATOR = "l.disco" ARRAY = "l.discos">    
      <MvASSIGN NAME = "l.ok" VALUE = "{ miva_array_insert( l.disco_list, l.disco, -1 ) }" />
    </MvFOREACH>

    Leave a comment:


  • K Series Parts
    replied
    array_elements does produce the correct number.

    I tried the direct assign and that produces the same result missing the first value.

    Leave a comment:


  • Scot - ScotsScripts.com
    replied
    First thing I would try is to make sure l.discos has three array elements by evaluating miva_array_elements(l.discos)

    Also, you may want to consider simply assign l.disco_list the l.discos array instead of going around with the miva_Array_insert...
    Code:
    <MvASSIGN NAME = "l.disco_list" VALUE = "{ l.discos }" />

    Leave a comment:


  • K Series Parts
    started a topic array_insert issue

    array_insert issue

    I am running into something that I can't really figure out or even explain. A very simplified version of the code and the result is below, it is dropping the first result for some reason.

    Code:
    <MvASSIGN NAME = "l.discos" VALUE = "{ miva_array_deserialize( Module_Product_Field_Value( l.module, Items.d.product_id, 'raves' ) ) }" />
    
    <MvFOREACH ITERATOR = "disco" ARRAY = "discos">
        <MvASSIGN NAME = "l.ok" VALUE = "{ miva_array_insert( l.disco_list, l.disco, -1 ) }" />
    </MvFOREACH>
    Custom Field = A,B,C
    l.discos = A,B,C
    l.disco_list = B,C
Working...
X