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?
Suggested Answer: D
Get Premium CCM-101 Questions
as Interactive Web-Based Practice Test or PDF
Real Exam Format
Detailed Explanations
Instant Access
Get Your Practice Test
14 comments · newest first
DO
Domitila
23 hours ago
I’m not sure, but C seems off. Declaring inside should be fine.
MY
Myrtie
6 days ago
I feel like A is a possibility. Custom Objects should be created by Jobs.
LI
Lindsey
11 days ago
I lean towards B. Missing middleware could cause issues.
DE
Desirae
16 days ago
Agreed, D makes sense. Without a Transaction, it won't save properly.
RI
Ricki
22 days ago
I think it's D. The Custom Object creation needs a Transaction.
RO
Rosita
27 days ago
CustomObjectMgr should be declared outside? That's new to me!
VE
Venita
1 month ago
B seems off, the middleware should be fine as is.
RY
Ryan
1 month ago
Wait, are you sure about that? I thought it was A.
CO
Corinne
1 month ago
Totally agree, D makes the most sense here.
MA
Marshall
2 months ago
I think it's D. Custom Object creation needs a Transaction.
DY
Dyan
2 months ago
I think Custom Objects can be created in routes, so option A seems unlikely. I'm leaning towards option D as well.
WA
Wade
2 months ago
I feel like the CustomObjectMgr variable being inside the route shouldn't cause a failure, but I could be wrong. Maybe it's option C?
BA
Barney
2 months ago
I remember practicing a similar question where the middleware was crucial. Could it be option B?
RO
Rodolfo
2 months ago
I'm not entirely sure, but I think option D might be the issue since creating Custom Objects usually requires a transaction.