Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to send multi-select attribute values to Acumatica

Tags:

c#

soap

acumatica

I can't find an example of this here or in the Acumatica sample code. Sending single attribute values works fine, but I can't find a way to send multi-select ones. They are returned as a comma-separated list in a string value, but sending them that way doesn't work. Also, sending them as multiple instances of single values doesn't work.

Here's what I've tried. (In the actual code I'm sending some other single attributes in the list, as well, but those work fine.)

// this results in nothing being set for the attribute
string interestedIn = "Brochure, Contact, Collecting small stones";
List<Acumatica.AttributeDetail> attributes = new List<Acumatica.AttributeDetail>();
attributes.Add(
    new Acumatica.AttributeDetail {
        Attribute = new Acumatica.StringValue { Value = "Interested in" },
        Value = new Acumatica.StringValue { Value = interestIn }
    }
);
custAdd.Attributes = attributes.ToArray();
// this results in the last item in the list being set for the attribute
string interestedIn = "Brochure, Contact, Collecting small stones";
List<Acumatica.AttributeDetail> attributes = new List<Acumatica.AttributeDetail>();
string[] interests = Convert.ToString(interestedIn).Split(',');
foreach (string interest in interests) {
    attributes.Add(
        new Acumatica.AttributeDetail {
            Attribute = new Acumatica.StringValue { Value = "Interested in" },
            Value = new Acumatica.StringValue { Value = interest.Trim() }
        }
    );
};
custAdd.Attributes = attributes.ToArray();
like image 979
CSX321 Avatar asked Feb 23 '26 15:02

CSX321


1 Answers

From the source

MappedCustomer obj = bucket.Customer;
Core.API.Customer impl = obj.Local;
impl.Attributes = impl.Attributes ?? new List<AttributeValue>();
AttributeValue attribute = new AttributeValue();
attribute.AttributeID = new StringValue() { Value = attributeID };
attribute.ValueDescription = new StringValue() { Value = attributeValue?.ToString() };
impl.Attributes.Add(attribute);

Some subtle differences here. Also, I wonder if the .ToArray() call is necessary.

like image 85
Patrick Chen Avatar answered Feb 26 '26 05:02

Patrick Chen