Clarification on adding custom fields

Hi,

I am writing an app in .NET 2.0 (C#).

I'm a little confused by something in the documentation, and in the schema.

I want to add a custom field to an existing email message.

I am not clear about the roll of the ModifyItem class... do I need to create an instance of this class in order to modify an item?

If I understand the documentation correctly, I want to use the modifyItemRequest() method. But the docs for this method don't reference the ModifyItem class at all.

Looking at the docs for modifyItemRequest(), it appears that I would need to do the following:

========================================
// assume I have an email message named "mail", of type Mail.
// assume my web services object is named "gw"

ItemChanges updates = new ItemChanges();
Custom custom = new Custom();
modifyItemRequest miReq = new modifyItemRequest();
modifyItemResponse miResp;

miReq.id = mail.id;
custom.field = "MyField";
custom.value = "Value of the field.";
updates.add = custom;
miReq.updates = updates;

miResp = gw.modifyItemRequest(miReq);
========================================

The problem I have is that the documentation says that ItemChanges.add should be of type "Item". Custom fields don't derive from the Item class, so that won't work.

Am I to understand that I need to create a NEW mail item in order to modify an EXISTING one?

Even if that's true, the .NET parsing of the WSDL doesn't seem to find a way to *add* custom field instances to ContainerItem.customs (type: CustomList). It's implemented as a fixed array (as far as I can tell).

1. What is the point/use of the ModifyItem class? How is it to be used (if at all)?
2. Am I right, I have to create a new Mail item in order to modify an existing one?
3. Can/will anyone shed any light on how this should happen (creating custom fields on existing items via SOAP)?

Much thanks...

--sk.

Tags:

  • You need to create an instance of the class to modify
    an item. I need the organization of the item to be
    in the structure specified by the schema. I can't find
    the customs element without looking in a ContainerItem.

    You don't need to have a fully filled out item, just
    what you want to change.

    I don't have an example in .NET. At least that I could
    do a quick search on an find. Here is a simple test in
    Java where I'm deleting custom fields. The concept should
    be the same.

    public void testCustomDelete() {
    Custom custom[] = new Custom[4];
    CustomList list = new CustomList();
    ItemChanges changes = new ItemChanges();
    Task task = new Task();

    custom[0] = new Custom( CustomType.String, "Test Field", null, null,
    false, null );
    custom[1] = new Custom( CustomType.Numeric, "Test Numeric", null,
    null, false, null );
    custom[2] = new Custom( CustomType.Date, "Test Date", null, null,
    false, null );
    custom[3] = new Custom( CustomType.Binary, "Test Binary", null, null,
    false, null );
    list.setCustom( custom );
    task.setCustoms( list );
    changes.setDelete( task );
    try {
    m_main.getService().modifyItemRequest( m_mitem.getId(), null, changes, 0,
    m_main.getSessionId(), m_main.getTrace() );
    } catch ( Exception e ) {
    e.printStackTrace();
    }
    }

    If you still need some help, let me know. It might take me awhile
    before I can look into it.

    Preston

    >>> On Thursday, November 13, 2008 at 10:21 AM, Sean

    Kirkby<skirkby@armordatasystems.com> wrote:
    > Hi,
    >
    > I am writing an app in .NET 2.0 (C#).
    >
    > I'm a little confused by something in the documentation, and in the

    schema.
    >
    > I want to add a custom field to an existing email message.
    >
    > I am not clear about the roll of the ModifyItem class... do I need to

    create
    > an instance of this class in order to modify an item?
    >
    > If I understand the documentation correctly, I want to use the
    > modifyItemRequest() method. But the docs for this method don't reference

    the
    > ModifyItem class at all.
    >
    > Looking at the docs for modifyItemRequest(), it appears that I would need

    to
    > do the following:
    >
    > ========================================
    > // assume I have an email message named "mail", of type Mail.
    > // assume my web services object is named "gw"
    >
    > ItemChanges updates = new ItemChanges();
    > Custom custom = new Custom();
    > modifyItemRequest miReq = new modifyItemRequest();
    > modifyItemResponse miResp;
    >
    > miReq.id = mail.id;
    > custom.field = "MyField";
    > custom.value = "Value of the field.";
    > updates.add = custom;
    > miReq.updates = updates;
    >
    > miResp = gw.modifyItemRequest(miReq);
    > ========================================
    >
    > The problem I have is that the documentation says that ItemChanges.add
    > should be of type "Item". Custom fields don't derive from the Item class,

    so
    > that won't work.
    >
    > Am I to understand that I need to create a NEW mail item in order to

    modify
    > an EXISTING one?
    >
    > Even if that's true, the .NET parsing of the WSDL doesn't seem to find a

    way
    > to *add* custom field instances to ContainerItem.customs (type:

    CustomList).
    > It's implemented as a fixed array (as far as I can tell).
    >
    > 1. What is the point/use of the ModifyItem class? How is it to be used

    (if
    > at all)?
    > 2. Am I right, I have to create a new Mail item in order to modify an
    > existing one?
    > 3. Can/will anyone shed any light on how this should happen (creating

    custom
    > fields on existing items via SOAP)?
    >
    > Much thanks...
    >
    > --sk.

  • Thanks, Preston. I think this will do. I will post a sample of .NET (C#) code in a few (after I test it).

    Any thoughts on the ModifyItem class? What's that for?

    --sk.


    >>> On 11/13/2008 at 10:39 AM, Preston Stephenson<PStephenson@gw.novell.com> wrote:


    You need to create an instance of the class to modify
    an item. I need the organization of the item to be
    in the structure specified by the schema. I can't find
    the customs element without looking in a ContainerItem.

    You don't need to have a fully filled out item, just
    what you want to change.

    I don't have an example in .NET. At least that I could
    do a quick search on an find. Here is a simple test in
    Java where I'm deleting custom fields. The concept should
    be the same.

    public void testCustomDelete() {
    Customcustom[] = new Custom[4];
    CustomListlist = new CustomList();
    ItemChangeschanges = new ItemChanges();
    Tasktask = new Task();

    custom[0] = new Custom( CustomType.String, "Test Field", null, null,
    false, null );
    custom[1] = new Custom( CustomType.Numeric, "Test Numeric", null,
    null, false, null );
    custom[2] = new Custom( CustomType.Date, "Test Date", null, null,
    false, null );
    custom[3] = new Custom( CustomType.Binary, "Test Binary", null, null,
    false, null );
    list.setCustom( custom );
    task.setCustoms( list );
    changes.setDelete( task );
    try {
    m_main.getService().modifyItemRequest( m_mitem.getId(), null, changes, 0,
    m_main.getSessionId(), m_main.getTrace() );
    } catch ( Exception e ) {
    e.printStackTrace();
    }
    }

    If you still need some help, let me know. It might take me awhile
    before I can look into it.

    Preston


    >>> On Thursday, November 13, 2008 at 10:21 AM, Sean

    Kirkby<skirkby@armordatasystems.com> wrote:

    > Hi,
    >
    > I am writing an app in .NET 2.0 (C#).
    >
    > I'm a little confused by something in the documentation, and in the

    schema.

    >
    > I want to add a custom field to an existing email message.
    >
    > I am not clear about the roll of the ModifyItem class... do I need to

    create

    > an instance of this class in order to modify an item?
    >
    > If I understand the documentation correctly, I want to use the
    > modifyItemRequest() method. But the docs for this method don't reference

    the

    > ModifyItem class at all.
    >
    > Looking at the docs for modifyItemRequest(), it appears that I would need

    to

    > do the following:
    >
    > ========================================
    > // assume I have an email message named "mail", of type Mail.
    > // assume my web services object is named "gw"
    >
    > ItemChanges updates = new ItemChanges();
    > Custom custom = new Custom();
    > modifyItemRequest miReq = new modifyItemRequest();
    > modifyItemResponse miResp;
    >
    > miReq.id = mail.id;
    > custom.field = "MyField";
    > custom.value = "Value of the field.";
    > updates.add = custom;
    > miReq.updates = updates;
    >
    > miResp = gw.modifyItemRequest(miReq);
    > ========================================
    >
    > The problem I have is that the documentation says that ItemChanges.add
    > should be of type "Item". Custom fields don't derive from the Item class,

    so

    > that won't work.
    >
    > Am I to understand that I need to create a NEW mail item in order to

    modify

    > an EXISTING one?
    >
    > Even if that's true, the .NET parsing of the WSDL doesn't seem to find a

    way

    > to *add* custom field instances to ContainerItem.customs (type:

    CustomList).

    > It's implemented as a fixed array (as far as I can tell).
    >
    > 1. What is the point/use of the ModifyItem class? How is it to be used

    (if

    > at all)?
    > 2. Am I right, I have to create a new Mail item in order to modify an
    > existing one?
    > 3. Can/will anyone shed any light on how this should happen (creating

    custom

    > fields on existing items via SOAP)?
    >
    > Much thanks...
    >
    > --sk.
  • ModifyItem is just for modifyItemsRequest.
    It allows you to specify separate information for each
    item that is being changed.

    Preston

    >>> On Thursday, November 13, 2008 at 11:06 AM, Sean

    Kirkby<skirkby@armordatasystems.com> wrote:
    > Thanks, Preston. I think this will do. I will post a sample of .NET (C#)


    > code in a few (after I test it).
    >
    > Any thoughts on the ModifyItem class? What's that for?
    >
    > --sk.
    >
    >>>> On 11/13/2008 at 10:39 AM, Preston

    Stephenson<PStephenson@gw.novell.com>
    > wrote:
    >
    > You need to create an instance of the class to modify
    > an item. I need the organization of the item to be
    > in the structure specified by the schema. I can't find
    > the customs element without looking in a ContainerItem.
    >
    > You don't need to have a fully filled out item, just
    > what you want to change.
    >
    > I don't have an example in .NET. At least that I could
    > do a quick search on an find. Here is a simple test in
    > Java where I'm deleting custom fields. The concept should
    > be the same.
    >
    > public void testCustomDelete() {
    > Customcustom[] = new Custom[4];
    > CustomListlist = new CustomList();
    > ItemChangeschanges = new ItemChanges();
    > Tasktask = new Task();
    >
    > custom[0] = new Custom( CustomType.String, "Test Field", null,

    null,
    > false, null );
    > custom[1] = new Custom( CustomType.Numeric, "Test Numeric", null,
    > null, false, null );
    > custom[2] = new Custom( CustomType.Date, "Test Date", null, null,
    > false, null );
    > custom[3] = new Custom( CustomType.Binary, "Test Binary", null,

    null,
    > false, null );
    > list.setCustom( custom );
    > task.setCustoms( list );
    > changes.setDelete( task );
    > try {
    > m_main.getService().modifyItemRequest( m_mitem.getId(), null, changes, 0,
    > m_main.getSessionId(), m_main.getTrace() );
    > } catch ( Exception e ) {
    > e.printStackTrace();
    > }
    > }
    >
    > If you still need some help, let me know. It might take me awhile
    > before I can look into it.
    >
    > Preston
    >
    >>>> On Thursday, November 13, 2008 at 10:21 AM, Sean

    > Kirkby<skirkby@armordatasystems.com> wrote:
    >> Hi,
    >>
    >> I am writing an app in .NET 2.0 (C#).
    >>
    >> I'm a little confused by something in the documentation, and in the

    > schema.
    >>
    >> I want to add a custom field to an existing email message.
    >>
    >> I am not clear about the roll of the ModifyItem class... do I need to

    > create
    >> an instance of this class in order to modify an item?
    >>
    >> If I understand the documentation correctly, I want to use the
    >> modifyItemRequest() method. But the docs for this method don't

    reference
    > the
    >> ModifyItem class at all.
    >>
    >> Looking at the docs for modifyItemRequest(), it appears that I would

    need
    > to
    >> do the following:
    >>
    >> ========================================
    >> // assume I have an email message named "mail", of type Mail.
    >> // assume my web services object is named "gw"
    >>
    >> ItemChanges updates = new ItemChanges();
    >> Custom custom = new Custom();
    >> modifyItemRequest miReq = new modifyItemRequest();
    >> modifyItemResponse miResp;
    >>
    >> miReq.id = mail.id;
    >> custom.field = "MyField";
    >> custom.value = "Value of the field.";
    >> updates.add = custom;
    >> miReq.updates = updates;
    >>
    >> miResp = gw.modifyItemRequest(miReq);
    >> ========================================
    >>
    >> The problem I have is that the documentation says that ItemChanges.add
    >> should be of type "Item". Custom fields don't derive from the Item

    class,
    > so
    >> that won't work.
    >>
    >> Am I to understand that I need to create a NEW mail item in order to

    > modify
    >> an EXISTING one?
    >>
    >> Even if that's true, the .NET parsing of the WSDL doesn't seem to find a

    > way
    >> to *add* custom field instances to ContainerItem.customs (type:

    > CustomList).
    >> It's implemented as a fixed array (as far as I can tell).
    >>
    >> 1. What is the point/use of the ModifyItem class? How is it to be used

    > (if
    >> at all)?
    >> 2. Am I right, I have to create a new Mail item in order to modify an
    >> existing one?
    >> 3. Can/will anyone shed any light on how this should happen (creating

    > custom
    >> fields on existing items via SOAP)?
    >>
    >> Much thanks...
    >>
    >> --sk.