0

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))

]%%
2
  • try to check the rowcount of @CMfunction, if the rowcount is 1 only then it will fetch the ID else it will not. Check it.
    – Abhishek
    Jul 11, 2018 at 11:54
  • It does return a value if i just output @form_position. So there should be a rowcount of 1... How can i test that? Jul 11, 2018 at 12:44

1 Answer 1

2

Do something like this.

%%[

    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)
    if rowcount(@CMfunction) > 0 then 
        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))  
    else
        set @result = "no record found"
    endif   

    ]%%
    %%=v(@result)=%%
1
  • 1
    I figured it out.. There was a permission set in Salesforce which states that you need to be 18 years old to create a Competence Profile. My test profile had a birthdate of 1 year old.. Thanks for your help Jul 11, 2018 at 13:58

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .