0

I made a cloud page in MC that allows me to update some field in SC

>   %%[ if RequestParameter("submitted") == true then ]%%
>          <p style="text-align:center; color: #000000; font-family: Arial, sans-serif ; font-weight:bold;font-size:14px;">Dziękujemy!</p> 
> <p style="text-align:center; color: #000000; font-family: Arial,
> sans-serif ;font-size:14px;"> Zmiany zostały zapisane. </p>
>       %%[ else ]%%     
>       <form action="%%=RequestParameter('PAGEURL')=%%" method="post">   <div>
>           <label align="center" for="scales">Jesteś pewien, że chcesz zrezygnować z otrzymywania od nas wiadomości?</label><br>  
>       <div> <input type="radio" id="NIE" name="Optin" value="False">
>           <label for="NIE">NIE</label> </div>
>       <div><input type="radio" id="TAK" name="Optin" value="True">
>           <label for="TAK">TAK</label></div>                  </div><br><br>
>          <input name="submitted" type="hidden" value="true" />
>          <input type="submit" value="POTWIERDŹ">
>       </form>
>       %%[ endif ]%%   </fieldset>    </div>    </tr></table></div>
>     %%[ Set @Id= '00Q9E000005akYkUAI'
> 
> if RequestParameter("submitted") == true then  
> UpdateSingleSalesforceObject("Lead",@Id,"OptInEmail__c", False,
> "OptInSMS__c", False) 
> endif   ]%%

and when I run the page and click on the button I have a server error(500 - Internal server error.)

0

The problem comes certainly from the UpdateDE function.

Fist of all, you need to use UpdateData instead of UpdateDE. UpdateDE only works in an email send while UpdateData is used with landing pages and SMS messages

The first parameter of the UpdateDE stands for the number of columns used to build WHERE clause. And since you are using one field to do the where, you need to use something like:

UpdateData("DE_Lead_PL", 1, "Id", @Id,"OptInEmail", False, "OptInSMS", False)

Update:

Your problem can be related to the UpdateSingleSalesforceObject function. You need to check that you have the permission to update data on Leads on your Sales/Service Cloud org.

Also, you need to take a look at validation rules (if there are any) on OptInEmail__c and OptInSMS__c fields.

And since you are using a hardcoded lead's id, I assume the lead exists. However, I would recommend checking if the lead exists before calling UpdateSingleSalesforceObject.

You can use something like:

SET @LookUpLeads = RetrieveSalesforceObjects('Lead', 'Id', 'Id', '=', '00Q9E000005akYkUAI')
 IF RowCount(@LookUpLeads) > 0 then
  UpdateSingleSalesforceObject("Lead",@Id,"OptInEmail__c", 'false',"OptInSMS__c", 'false') 
ENDIF
  • thank you for your help it was an error the updateDE doesn't belong to this page i remove it but still have the same issue thank you – WassiM Nov 25 '19 at 13:54
  • Okey, I've updated my answer accordingly – Rachid Mamai Nov 25 '19 at 14:25
  • Thank you for your help I'll try your code the ID I use is just for testing after the page work I'm not using a hardcoded ID I keep you in touch when I finish the test – WassiM Nov 25 '19 at 15:34
  • Hello i try the solution but it still doesn't work and in SC there is no call in the logs – WassiM Nov 26 '19 at 9:02

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.