SalesforceLabs / survey-force

85 stars 61 forks source link

Some error occured while saving response #40

Closed Eddies303 closed 5 years ago

Eddies303 commented 5 years ago

Hi, I'm trying to configure Survey Force for our organisation.

Now I'm stuck at a certain point and I hope somebody over here knows what to do.

1) I followed the configuration intructions. 2) I'm working with the sample survey. 3) I send the survey to customers (external)
a) Sharing options: Email link with contact merge b) Select site: Surveys

4) Our customers are able to see and fill in the survey 5) but when they trie to submit ... there is this error: "Some error occured while saving response" 6) in Salesforce debuglog I see this "Attempt to de-reference a null object" . But I have no idea if this is the cause or what to do.

apex-07L1r00004fkUReEAM.log

Does anybody know how to overcome this problem?

Thank you in advance! Ed

jrattanpal commented 5 years ago

Hi,

From what I can see (by just reading the debug log; can't execute it), it's happening in method private Boolean AddSurveyTaker() on line#350

Error itself seems to be happening at if(caseId.toUpperCase() =='none'|| caseId.length()<5) on line#358

You can try to test it by changing the following code

if(caseId.toUpperCase() =='none'|| caseId.length()<5)
          caseId = null;    
        if(contactId.toUpperCase() =='none'|| contactId.length()<5)
          contactId = null;         
        if (anonymousAnswer != 'Anonymous')
        {
            userId = UserInfo.getUserId();
        }
        else
        {
            userId = null;
        }

        if(anonymousAnswer != 'Anonymous' && (contactId != null || caseId != null))

TO (haven't tested it for syntax)

if(caseId != null && (caseId.toUpperCase() =='none'|| caseId.length()<5))
          caseId = null;    
        if(contactId != null && (contactId.toUpperCase() =='none'|| contactId.length()<5))
          contactId = null;         
        if (anonymousAnswer != 'Anonymous')
        {
            userId = UserInfo.getUserId();
        }
        else
        {
            userId = null;
        }
Eddies303 commented 5 years ago

Thank you Jrattanpal ,

Since I'm not a devellopper but only an admin, I have this other question:

Can you tell me were I can find this code? I want to try your suggestion but I do not know where to find that fragment of code.

jrattanpal commented 5 years ago

You can use Developer console to edit the code.

https://trailhead.salesforce.com/en/content/learn/modules/developer_console/developer_console_intro

Then you can make the change and test. I suggest not to do it in production but test it in sandbox first. Although, you can't edit it in active production org anyways. You will need to change it in sandbox and then move to production.

However, to move Apex code to production, you need to also make sure you move Apex Unit tests for code coverage or system won't let you move it. So you will definitely need developer help.

But first step, test if it works

Eddies303 commented 5 years ago

thank you for your detailed answer.