Deal of The Day! Hurry Up, Grab the Special Discount - Save 25% - Ends In 00:00:00 Coupon code: SAVE25
Welcome to Pass4Success

- Free Preparation Discussions

Salesforce Certified B2C Commerce Developer (Comm-Dev-101) Exam - Topic 10 Question 22 Discussion

A Newsletter controller contains the following route:Server.post('Subscribe', function (req,res,next){var newsletterForm = server.forms.getForm('newsletter');var CustomObjectMgr = require('dw/object/CustomObjectMgr');if(newsletterForm.valid){try{var CustomObject =CustomObjectMgr.createCustomObejct('NewsletterSubscription', newsletterform.email.value);CustomObject.custom.firstName = newsletterForm.fname.value;CustomObject.custom.lastName = newsletterForm.lname.value;-} catch(e){//Catch error here}}next();});Assuming the Custom Object metadata exists, why does this route fail to render the newsletter templatewhen the subscription form is correctly submitted?
D) The Custom Object creation is not wrapped in a Transaction.
A) Custom Objects can only be created by Job scripts
B) The Subscribe route is missing the server.middleware.httpt middleware.
C) The CustomObjectMgr variable should be declare outside of the route.

Salesforce Certified B2C Commerce Developer (Comm-Dev-101) Exam - Topic 10 Question 22 Discussion

Actual exam question for Salesforce's Salesforce Certified B2C Commerce Developer (Comm-Dev-101) exam
Question #: 22
Topic #: 10
[All Salesforce Certified B2C Commerce Developer (Comm-Dev-101) Questions]

A Newsletter controller contains the following route:

Server.post('Subscribe', function (req,res,next){

var newsletterForm = server.forms.getForm('newsletter');var CustomObjectMgr = require('dw/object/CustomObjectMgr');

if(newsletterForm.valid){

try{

var CustomObject =

CustomObjectMgr.createCustomObejct('NewsletterSubscription', newsletterform.email.value);

CustomObject.custom.firstName = newsletterForm.fname.value;

CustomObject.custom.lastName = newsletterForm.lname.value;-

} catch(e){

//Catch error here

}

}

next();

});

Assuming the Custom Object metadata exists, why does this route fail to render the newsletter template

when the subscription form is correctly submitted?

Show Suggested Answer Hide Answer
Suggested Answer: D

Contribute your Thoughts:

0/2000 characters
Buddy
10 months ago
The middleware part seems like a red herring to me.
upvoted 0 times
...
Denny
10 months ago
I agree, missing the transaction is a common mistake.
upvoted 0 times
...
Malinda
10 months ago
Wait, can Custom Objects really only be created by Job scripts? That sounds off.
upvoted 0 times
...
Scarlet
11 months ago
Definitely, it needs to be in a transaction!
upvoted 0 times
...
Jennifer
11 months ago
I think the issue is with the transaction not being wrapped.
upvoted 0 times
...
Gail
11 months ago
I'm not sure about the placement of the CustomObjectMgr variable. It seems like it should work either way, but maybe C has some merit?
upvoted 0 times
...
Twila
11 months ago
I think the issue might be with the transaction. We practiced a similar question where wrapping operations in a transaction was crucial. D could be the answer.
upvoted 0 times
...
Blythe
11 months ago
I feel like the middleware part could be important, but I can't recall if it's specifically required for this route. Maybe B is worth considering?
upvoted 0 times
...
Sherell
11 months ago
I remember we discussed that Custom Objects can be created in various contexts, not just Job scripts, so I don't think A is the right answer.
upvoted 0 times
...
Antonio
11 months ago
Okay, let's think this through. We need to identify the roles of the systems involved in this scenario.
upvoted 0 times
...
Mirta
11 months ago
I think the key here is to focus on the classification method, so I'm going to look for an answer that describes a step in that process.
upvoted 0 times
...

Save Cancel