Topic
  • 3 replies
  • Latest Post - ‏2013-10-31T17:47:39Z by llandale
strathglass
strathglass
129 Posts

Pinned topic Copy attribute value from one object to another - multi-value enum?

‏2013-10-31T15:36:12Z |

 

Is there no easy way to copy an attribute value from one object to another when the attribute is a multi-valued enumeration?

I did find a klugey solution that copied the source value to a string, and then extracted each line of the string and then assigned each of those to the target.

But I thought there would be a more elegant way...like:

Object o_source, o_target

string multiEnumAttr="Allocation"

o_target.multiEnumAttr = o_source.multiEnumAttr

But that doesn't work.

-Colin

  • llandale
    llandale
    3035 Posts

    Re: Copy attribute value from one object to another - multi-value enum?

    ‏2013-10-31T17:21:35Z  

    If your "Allocation" attribute is defined the same way in both modules your assignment should work.  Except, well, you need to turn the attr reference into a string by double-double quotes:

    • oT.Name = oS.Name ""

    There is a better undocumented perm which copies everything.

    • string ErrorMessage = set(oT.Name, oS.Name)

    But, as always, the data being copied needs to be compatible with the "type" of the target attribute.  Noteworthy would be you cannot copy a multi-value that has more than one selected into a single value (since the copied value has an EOL in it); and of course the copied values have to exist in the target attr type.

    -Louie

  • strathglass
    strathglass
    129 Posts

    Re: Copy attribute value from one object to another - multi-value enum?

    ‏2013-10-31T17:25:38Z  
    • llandale
    • ‏2013-10-31T17:21:35Z

    If your "Allocation" attribute is defined the same way in both modules your assignment should work.  Except, well, you need to turn the attr reference into a string by double-double quotes:

    • oT.Name = oS.Name ""

    There is a better undocumented perm which copies everything.

    • string ErrorMessage = set(oT.Name, oS.Name)

    But, as always, the data being copied needs to be compatible with the "type" of the target attribute.  Noteworthy would be you cannot copy a multi-value that has more than one selected into a single value (since the copied value has an EOL in it); and of course the copied values have to exist in the target attr type.

    -Louie

    Thanks Louie, I'll try that ... I was sure I had tried the double quote cast thing, but maybe not (or maybe I only tried it on the left hand).

    (I was figuring it was a syntax issue!)

    The two objects are in the same module and its the same attribute (just copying from one obj to another), so there really should be no issue.

    I didn't know about the perm, so that is good to know.

    Thanks again

    -Colin

  • llandale
    llandale
    3035 Posts

    Re: Copy attribute value from one object to another - multi-value enum?

    ‏2013-10-31T17:47:39Z  
    • llandale
    • ‏2013-10-31T17:21:35Z

    If your "Allocation" attribute is defined the same way in both modules your assignment should work.  Except, well, you need to turn the attr reference into a string by double-double quotes:

    • oT.Name = oS.Name ""

    There is a better undocumented perm which copies everything.

    • string ErrorMessage = set(oT.Name, oS.Name)

    But, as always, the data being copied needs to be compatible with the "type" of the target attribute.  Noteworthy would be you cannot copy a multi-value that has more than one selected into a single value (since the copied value has an EOL in it); and of course the copied values have to exist in the target attr type.

    -Louie

    Oops, looking at my notes.  "set" returns nothing, you need to wrap it:

    • noError()
    • set(oT.Name, oS.Name)
    • ErrMess = lastError()