I am trying to update Subscriber status using following Ampscript code. Can someone please assist on what could be wrong with the code. It gives following error message -

Error Message: Update or insert of view or function 'C7229040._subscribers' failed because it contains a derived or constant field.

Code :




you can not use DataView to update the subscriber status. you should use API AmpScript functions and below is the sample code for your reference.

SET @Subscriber = CreateObject("Subscriber")
SetObjectProperty(@Subscriber, "SubscriberKey","test@gmail.com")
SetObjectProperty(@Subscriber, "EmailAddress", "test@gmail.com")
SetObjectProperty(@Subscriber, "Status", "Active" )
SET @Status = InvokeUpdate(@Subscriber, @createErrDesc, @createErrNo, @createOpts)


The following lines work for me. The @Unsub_All variable either took the value of "Active" or "Unsubscribed".

Note: This code is on a landing page belonging to a business unit of the SFMC instance.


/*Update the unsubscribe from all list*/  
SET @ll_sub = CreateObject("Subscriber")

SetObjectProperty(@ll_sub,"EmailAddress", @SubscriberKey)
SetObjectProperty(@ll_sub,"SubscriberKey", @SubscriberKey)

SET @client = CreateObject("ClientID")
SetObjectProperty(@client, "ID", @memberID)
SetObjectProperty(@client, "IDSpecified", "true")
SetObjectProperty(@ll_sub, "Client", @client)

SetObjectProperty(@ll_sub,"Status", @Unsub_All)
Set @options = CreateObject("UpdateOptions")
Set @save = CreateObject("SaveOption")
AddObjectArrayItem(@options,"SaveOptions", @save)

/* Here is where we actually update the Subscriber object */
Set @update_sub = InvokeUpdate(@ll_sub, @update_sub_status, @update_sub_errorcode, @options)


Thanks for sharing Adam, do you know how to pull the MID dynamically @memberID?. Your code above works great, except that I had to hardcode the MID that I was working on.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.