Announcement

Collapse
No announcement yet.

How to update Custom Field values in Miva 9 using Customer_Update API

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

    How to update Custom Field values in Miva 9 using Customer_Update API

    How to update Custom Field value in Miva 9 using Customer_Update Function,
    Below is my python code snippet :

    from merchantapi.model import CustomFieldValues


    request = CustomerUpdate(client)

    # Setup our request variables
    request.set_customer_id('25')

    test1 = { "ERP_NO": "111" }

    request.set_custom_field_values(CustomFieldValues( test1))

    # Send the request
    response = request.send()

    here I am getting below error while setting CustomFieldValues( test1))

    MER-CUS-JSN-00062 - Module 'ERP_NO' not found

    #2
    You are almost correct. The way you are constructing and setting your custom field values requires that you build it as a dictionary with the key being the module implementing the custom fields and its value a dictionary of key value pairs for that module. The default module that implements custom fields is customfields

    If you wish to construct it like you are currently doing, you would need to format it like so:

    Code:
    test1 =
    {
    "customfields" : {
    "ERP_NO": "111"
    }
    }
    Alternately, you can set a single one using the add_custom_field method of the CustomFieldValues object:

    Code:
    request.get_custom_field_values().set_custom_field _value( 'ERP_NO', '111', 'customfields' );
    The 3rd argument is optional, it defaults to customfields I just included it for clarity.

    Comment


      #3
      Sorry, that method to set a single set/insert should be:

      Code:
      request.get_custom_field_values().add_value( 'ERP_NO', '111', 'customfields' )

      Comment


        #4
        This line of code worked for me.

        request.get_custom_field_values().add_value( 'ERP_NO', '111', 'customfields' )

        Thanks gidriss

        Comment

        Working...
        X