I tried to figure out what the problem of my code is but couldnt find it. Hope someone can help.
I got the following error:
Invalid index (parameter 2) passed to Row function. Index must be less than or equal to the row count. Index Value: 1 Row Count: 0 Function: ROW(@CMfunction,1)
This is the code:
%%[
SET @thankyou_pageID = "2539"
/* subscriberKey is required */
SET @subscriberKey = [_subscriberkey]
IF @subscriberkey == "" THEN
Redirect(CloudPagesURL(@error_pageID, "msg", "Not found"))
ENDIF
/* POSTED FORM FIELDS */
SET @form_firstname = RequestParameter("FirstName")
SET @form_lastname = RequestParameter("LastName")
SET @form_position = RequestParameter("Position")
SET @CMname = CONCAT(@form_firstname ,@form_lastname ,'- ',@form_position)
Set @CMfunction = RetrieveSalesforceObjects('CM_Function__c', 'Id', 'Name', '=', @form_position)
Set @Opprow = ROW(@CMfunction,1)
Set @CMvalue = FIELD(@Opprow ,'Id')
CreateSalesforceObject('cm_competence_profile__c',8,
'candidate__c',@subscriberkey,
'CM_function__c',@CMvalue,
'name',@CMname,
'Default_Assessment_Internal_Verifier__c','005w0000003sEHPAA2',
'Internal_Verifier__c','005w0000003sEHPAA2',
'OwnerId','005w0000003sEHPAA2',
'Stage__c','In Progress',
'RecordTypeId','012w0000000V3nHAAS')
UpdateSingleSalesforceObject('contact',@subscriberkey,'AcpInvitationStatus__c','Accepted')
/* To thank you page after processing */
Redirect(CloudPagesURL(@thankyou_pageID))
]%%