how to update a subscriber attributes with the values I already have in some variables in ampscript


var @x

set @x=1

/* Crear el objeto del subscriptor */ set @subscriber = CreateObject( "Subscriber" ) SetObjectProperty( @subscriber, "EmailAddress", @subKey ) SetObjectProperty( @subscriber, "SubscriberKey", @subKey )

    /* Get all the subscriber attributes */
    SET @rr2 = CreateObject("RetrieveRequest")
    AddObjectArrayItem(@rr2, "Properties", "EmailAddress")
    AddObjectArrayItem(@rr2, "Properties", "SubscriberKey")
    AddObjectArrayItem(@rr2, "Properties", "ID")

    /* Create a filter be the subscriber Id */
    SET @sfp2 = CreateObject("SimpleFilterPart")
    SET @sub_rowset = InvokeRetrieve(@rr2, @rrStatus, @rrRequestID)
    output(concat("rrStatus: ", @rrStatus,"<br>"))
    output(concat("<br>rrRequestID: ", @rrRequestID,"<br>"))
    output(concat("<br>rrRequestID: ", @rr2,"<br>"))

    IF ROWCOUNT(@sub_rowset) == 1 THEN
        SET @sub_row = ROW(@sub_rowset,1)
        SET @SubscriberKey = FIELD(@sub_row,"SubscriberKey")
        SET @Status = FIELD(@sub_row,"Status")
        SET @EmailAddress = FIELD(@sub_row,"EmailAddress")
        SET @Attributes = FIELD(@sub_row,"Attributes")

        OutputLine(CONCAT("SubscriberKey: ",V(@SubscriberKey),"<br />"))
        OutputLine(CONCAT("Status: ",V(@Status),"<br />"))
        OutputLine(CONCAT("email: ",V(@EmailAddress),"<br />"))

    SET @aRC = RowCount(@a)
    FOR @i=1 TO @aRC DO
       SET @aRow = ROW(@a,@i)
       SET @Name = FIELD(@aRow,"Name")
       SET @Value = FIELD(@aRow,"Value")
      OutputLine(CONCAT(@Name, ": ", @Value,"<br />")) /*muestra el atributo y su contenido
    NEXT @i


So far it shows me the attributes of the subscribers but I don't know if I need to save the value of each attribute in a different variable, to update only the attributes I need to update,
I know that an attribute is called innovation and I need to put the value of the variable @x to the innovation attribute, but I don't know how I could do it. I appreciate your help.

Your Answer

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

Browse other questions tagged or ask your own question.