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 Comm-Dev-101 Exam - Topic 4 Question 6 Discussion

Which snippet works correctly when updating the package.json file to point to the hook file for a cartridge?
A) { 'hooks': './cartridge/scripts/hooks.json' }
B) { 'hooks': './scripts/hooks.json' }
C) { hooks: './cartridge/scripts/hooks.json' }

Salesforce Comm-Dev-101 Exam - Topic 4 Question 6 Discussion

Actual exam question for Salesforce's Comm-Dev-101 exam
Question #: 6
Topic #: 4
[All Comm-Dev-101 Questions]

Which snippet works correctly when updating the package.json file to point to the hook file for a cartridge?

Show Suggested Answer Hide Answer
Suggested Answer: A

The cartridge's root-levelpackage.jsonuses the'hooks'property to point to the hook registration file. In the standard SFRA cartridge structure, the hook-registration file resides under:

cartridge/scripts/hooks.json

Therefore, the correct relative path is:

{'hooks':'./cartridge/scripts/hooks.json'}

Salesforce's SFRA hook documentation confirms thatpackage.jsonuses thehookskeyword to identify the hook file and that the referenced hook file then maps extension-point names to script implementations.

Option B omits thecartridgeportion of the normal directory structure, so it points to the wrong location. Option C uses JavaScript-object syntax rather than valid JSON because thehooksproperty name is unquoted. Apackage.jsonfile must contain valid JSON.

Thehooks.jsonfile contains entries with the extension-pointnameand correspondingscriptmodule. Once the cartridge is deployed and active on the appropriate cartridge path, registered hooks can participate in storefront or platform extension points.

Study Guide reference:Application Development --- hook registration,package.json,hooks.json, cartridge structure, CommonJS hook modules, and extension points.

===============


Contribute your Thoughts:

0/2000 characters
Florinda
1 day ago
I remember practicing a similar question, and I feel like the correct format should include quotes around "hooks".
upvoted 0 times
...
Keith
7 days ago
I think it might be option A, but I'm not entirely sure if the path is correct.
upvoted 0 times
...

Save Cancel