<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Jatin Patel on Medium]]></title>
        <description><![CDATA[Stories by Jatin Patel on Medium]]></description>
        <link>https://medium.com/@jatin29?source=rss-3bb25ea9590f------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*wn_PpeDMZigfSocC9hO67A.png</url>
            <title>Stories by Jatin Patel on Medium</title>
            <link>https://medium.com/@jatin29?source=rss-3bb25ea9590f------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 29 Nov 2026 11:46:25 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@jatin29/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Read-only Price book in Salesforce Commerce Cloud]]></title>
            <link>https://jatin29.medium.com/read-only-price-book-in-sfra-1ff01088d718?source=rss-3bb25ea9590f------2</link>
            <guid isPermaLink="false">https://medium.com/p/1ff01088d718</guid>
            <category><![CDATA[salesforce-commerce-cloud]]></category>
            <category><![CDATA[read-only-price-book]]></category>
            <category><![CDATA[demandware]]></category>
            <category><![CDATA[price]]></category>
            <category><![CDATA[sfra]]></category>
            <dc:creator><![CDATA[Jatin Patel]]></dc:creator>
            <pubDate>Tue, 08 Aug 2023 02:31:47 GMT</pubDate>
            <atom:updated>2023-10-05T03:08:09.495Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/750/0*U8VqYNRgm_Ja4Lix.JPG" /></figure><p>Welcome to my latest blog post on the topic of Read-only Price book. As I was working on a new project where clients requirement was the price will change very frequent(every 10 to 15 mins or lesser) for certain products(Gold products). So ideally if we change price of few products we need to rebuild the search index and when we are changing price very frequent its not good practice to rebuild the search index every 15 mins. So we require a solution that ensures the price changes are immediately reflected on the front-end side.</p><p>In this scenario, the Read-only Price book emerges as a solution to address the mentioned issue. This blog will walk you through the step-by-step process of creating, configuring, and effectively utilizing the Read-only Price book.</p><p>By the time you finish reading, you will have a thorough grasp of this feature and know exactly when to implement it. So, continue reading to explore all the details and insights.</p><h3>Table of content</h3><ol><li>What is Read-only Price book</li><li>Configuration of Read-only Price book</li><li>Pros and Cons of Read-only Price Book:</li><li>Urgent Price Changes during Emergency</li></ol><h3>What is Read-only Price book</h3><p>A read-only price book is like a standard editable price book, but you can’t change the prices or price tables directly in the business manager. To update the prices, you have to reimport the price book.</p><p>It’s an XML-based price book that offers significant advantages over a standard editable price book. It imports at least 60% faster and can accommodate up to 300 million prices. This type of price book is particularly beneficial for customers dealing with a large number of prices that require frequent updates.</p><p>Due to the specific storage technology employed in read-only price books, you cannot make individual price or price table updates using the standard Business Manager process. Instead, to update prices, you need to edit them in your external system and then reimport the updated price book.</p><p>In case of emergencies, where immediate price book updates are necessary, there is a workaround available in Business Manager. More details on this workaround can be found in the topic titled “<strong>Urgent Price Changes during Emergency</strong>” later in this discussion.</p><h3>Configuration of Read-only Price book</h3><ul><li>In order to import and utilize your existing price books as read-only, the user must enable the “<strong>Import All Price Books as Read Only</strong>” preference in the <strong>Administration &gt; Global Preferences &gt; Import and Export</strong> section.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/926/1*2NgynGVRfh4X8dI3ZuvV2w.png" /><figcaption>Administration &gt; Global Preferences &gt; Import &amp; Export</figcaption></figure><ul><li>If the user cannot locate the “<strong>Import All Price Books as Read Only</strong>” preference under Global Preferences &gt; Import and Export, they should navigate to <strong>Administration &gt; Global Preferences &gt; Feature Switches</strong> and activate the <strong>High Scale Price Books Feature</strong>, as illustrated in the image below.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CRkeaju_sF1-G0YTXlrOjw.png" /><figcaption>Administration &gt; Global Preferences &gt; Feature Switches</figcaption></figure><ul><li>To switch from read-only price book import to a standard price book import, the user must disable both the “Import All Price Books as Read Only” feature found in Administration &gt; Global Preferences &gt; Import and Export, and the “High Scale Price Books Feature” located in Administration &gt; Global Preferences &gt; Feature Switches.</li><li>If you encounter the warning message below (as shown in the image), while importing the price book, it indicates that you are importing the price book as a read-only version.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*P879cyh8oM-T4ImwmOYy-w.png" /><figcaption>Price book import and export</figcaption></figure><h3>Pros and Cons of Read-only Price Book</h3><h4>Pros:</h4><ul><li>The read-only price book offers faster imports, at least 60% quicker than the standard editable price book, and performs best in the replace mode during import.</li><li>It can handle a large volume of prices, up to 300 million, making it ideal for customers with extensive pricing data.</li><li>Unlike other price books, read-only price books do not require product indexing for prices to be effective in the search index.</li><li>The read-only nature prevents accidental price modifications within the Business Manager, as direct changes to values are not possible.</li></ul><h4>Cons:</h4><ul><li>Editing prices and price tables directly within the Business Manager is not possible, which means any updates must be done through reimports from external systems. This involves making changes in the external system and then reimporting the updated data into the price book.</li><li>It is not recommended for merchants who manage only a few price books directly in the Business Manager since, we can not change prices through Business manager.</li><li>The features of the read-only price book do not function properly if you have a combination of both editable and read-only price books. In such cases, the editable price book will always overwrite the read-only price book.</li><li>In emergency scenarios, the usual process for price updates might be more time-consuming, requiring workarounds in Business Manager.</li></ul><h3>Urgent Price Changes during Emergency</h3><ul><li>When you need to update a price in a read-only price book, you can do so by modifying it in the external source and then reimporting the price book. However, in emergency situations, you can use a workaround within Business Manager to directly update the price in Commerce Cloud.</li><li>The workaround involves creating an editable price book with the updated price and rebuilding the search indexes. Since editable price books always have priority over read-only price books, the new price will take effect. It is recommended to update the price in the XML source and delete all the updated price books by the end of the day.</li><li>Below are the steps to create a price book and assign updated price to specific products:</li></ul><ol><li>Select <strong>Merchant Tools &gt; site &gt; Products and Catalogs &gt; Price Books </strong>and Click <strong>New</strong>.</li><li>Enter an ID for the price book, select a currency and click <strong>Apply.</strong></li><li>On the Site Assignments tab, select one or more sites to assign the price book to and click <strong>Apply.</strong></li><li>On the Price Definitions tab, search for the product that you want to update the price for.</li><li>Enter a new price in the Price Table column and click <strong>Apply.</strong></li><li>Navigate to <strong>Merchant Tools &gt; Search &gt; Search Indexes </strong>select <strong>Product Index</strong> and click <strong>Rebuild.</strong></li><li>Once you have updated the price in your external system and reimported it using read-only price books, make sure to delete the price book created for the override.</li></ol><h3>Did you know?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/730/0*v0oayk-d7qq8eHgn" /><figcaption>QWERTY</figcaption></figure><p>The QWERTY keyboard layout was designed to slow typists down: The QWERTY layout was originally developed for mechanical typewriters to prevent the keys from jamming when typing too fast.</p><p>I am eagerly anticipating your valuable feedback and insights, which you can share with me either here or on <a href="https://linkedin.com/in/jatin291192">LinkedIn</a>. Your comments are greatly appreciated and will help me to continually improve and enhance my understanding and capabilities. Thank you in advance for taking the time to share your thoughts and insights with me.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1ff01088d718" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Difference between SearchOrders Vs ProcessOrders in Salesforce Commerce Cloud]]></title>
            <link>https://jatin29.medium.com/difference-between-searchorders-vs-processorders-in-sfra-1426d7c1a241?source=rss-3bb25ea9590f------2</link>
            <guid isPermaLink="false">https://medium.com/p/1426d7c1a241</guid>
            <category><![CDATA[salesforce-commerce-cloud]]></category>
            <category><![CDATA[demandware]]></category>
            <category><![CDATA[order-management]]></category>
            <category><![CDATA[sfra]]></category>
            <category><![CDATA[orders]]></category>
            <dc:creator><![CDATA[Jatin Patel]]></dc:creator>
            <pubDate>Mon, 03 Jul 2023 09:44:07 GMT</pubDate>
            <atom:updated>2023-10-05T03:08:33.910Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VasQJfesv2HHEAiri4bQSA.jpeg" /></figure><p>Greetings, readers! In this blog post, I am thrilled to share my latest findings on the OrderMgr methods. As I delved into one of these methods, I realized that there are several other methods associated with retrieving order data. However, many developers may not have a complete understanding of when to use each method and their respective advantages and disadvantages. I have compiled a comprehensive guide on the OrderMgr methods to address this gap. By the end of this post, you will have gained a solid comprehension of these methods. So, don’t miss out on this exciting opportunity, and read on for all the details! 😎</p><h3>Table of Contents</h3><ol><li>Difference between searchOrders vs processOrders</li><li>A Comprehensive Discussion of searchOrders and processOrders</li><li>Things to utilize while generating a query</li><li>Things to remember while using searchOrders/processOrders Method</li></ol><h3>Difference between searchOrders vs processOrders</h3><p>In order to retrieve order data, there are two commonly used methods, each with its own unique characteristics. It’s essential to understand the differences between these methods in order to choose the one that best fits your needs. So, let’s delve into what sets them apart.</p><p><strong>Limitations in retrieving data</strong></p><ul><li>The searchOrder method is designed to retrieve data from a database, but with a limitation. It can only retrieve the top 1000 records from the database, regardless of the total number of records available. This limitation is set to ensure that the method can perform efficiently and within acceptable response times. Therefore, if you need to retrieve less than 1000 records, you may consider this method.</li><li>On the other hand, the processOrder method has no such limitation. It is designed to process data without any restriction on the number of records. This means that you can use the method to process a large volume of data without any concern for limitations.</li></ul><p><strong>Data sorting feature</strong></p><ul><li>The searchOrder method allows you to sort data based on any attribute in ascending or descending order. This is an optional feature that allows you to customize the way data is sorted based on your specific needs.</li><li>On the other hand, the processOrder method does not have such a sorting functionality. It is designed to process data without any sorting requirements.</li></ul><p><strong>Method implementation style</strong></p><ul><li>The searchOrder method retrieves all the top 1000 orders and then processes them. This means that the entire batch of orders is retrieved first, and then the processing begins.</li><li>On the other hand, the processOrder method implements the callback function, which allows for the processing of one order at a time, without the need to wait for the entire batch to be retrieved first.</li></ul><h3>A Comprehensive Discussion of searchOrders and processOrders</h3><h4><strong>- The “searchOrders” Method</strong></h4><p>In the context of a storefront session, an insecure order access takes place when the following conditions are met:</p><ol><li>The current storefront session is different from the session in which the order was originally created.</li><li>The customer associated with the session does not correspond to the customer linked to the order.</li></ol><p>The functionalities of getOrder(String) and searchOrders(String, String, Object…) can be restricted by the ‘Limit Storefront Order Access’ site preference, which can be found in the <strong>Merchant Tools &gt; Site Preferences &gt; Orders.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kWfH6H2w2Ut6WXQTJe2XSg.png" /><figcaption><strong>Limit Storefront Order Access</strong></figcaption></figure><p>In case of an insecure order access:</p><ul><li>If the ‘Limit Storefront Order Access’ is active, the action is prohibited, and a SecurityException is thrown with a message starting with ‘Unauthorized access to order’.</li><li>If the ‘Limit Storefront Order Access’ is not active, a SecurityException is logged as an error with a message starting with ‘Unauthorized access to order’.</li></ul><p>In addition, the storefront should ensure the shopper is properly authenticated and authorized to read or modify the content of an order object.</p><p>— — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — —</p><p><strong>static searchOrders(queryAttributes : </strong><a href="https://documentation.b2c.commercecloud.salesforce.com/DOC1/topic/com.demandware.dochelp/DWAPI/scriptapi/html/api/class_dw_util_Map.html"><strong>Map</strong></a><strong>, sortString : </strong><a href="https://documentation.b2c.commercecloud.salesforce.com/DOC1/topic/com.demandware.dochelp/DWAPI/scriptapi/html/api/class_TopLevel_String.html"><strong>String</strong></a><strong>) : SeekableIterator</strong></p><p><strong>Parameters:</strong></p><ol><li>queryAttributes — a set of key-value pairs that define the query.</li><li>sortString — an optional sorting or null if no sorting is necessary.</li></ol><p>— — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — —</p><ul><li>The query results are provided as a SeekableIterator, which represents a set of results that can be traversed. The maximum number of orders in the result set is limited to 1000.</li><li>It is strongly recommended to call SeekableIterator.close() on the returned SeekableIterator if not all of its elements are being retrieved. This will ensure the proper cleanup of system resources.</li></ul><h4><strong>- The “processOrders” Method</strong></h4><p>If you’re looking to efficiently process a large set of orders, you may find the processOrders method to be a helpful method. This method allows for the execution of a user-defined function on a set of orders, making it ideal for use in batch processes and jobs that involve the processing of large result sets.</p><p>— — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — —</p><p><strong>OrderMgr.processOrders(processFunction : Function, queryString : String, args : Object…)</strong></p><p><strong>Parameters:</strong></p><ol><li>processFunction — the callback function to execute for each order</li><li>queryString — the query string to use when searching for an order.</li><li>args — the query string arguments.</li></ol><p>— — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — —</p><p>To configure the search, a simple query language is available, which provides the most commonly used filter and operator functionalities. The callback function, meanwhile, will receive a single argument of type “Order”.</p><p>If additional arguments are defined in the callback function, they will be undefined when called. If no arguments are defined in the method, it will still be called.</p><p>In the event that an error occurs during the execution of the callback, it will be logged and the process will continue with the next element from the result set. This feature ensures that the execution of the process is not halted by errors.</p><p>This method can be used as in this example</p><pre>var count=0;<br>function callbackFunction(order: Order)<br>{<br>   count++;<br>   dw.system.Logger.debug(&quot;order found: &quot;+order.documentNo)<br>}<br>OrderMgr.processOrders(callbackFunction, &quot;createdDate&lt;=08-09-2022&quot;);<br>dw.system.Logger.debug(&quot;found &quot;+count+&quot; orders which is older than 08-09-2022&quot;);</pre><p><strong>Things to remember</strong></p><ul><li>The processOrder method is highly efficient for processing large volumes of orders. Although it does not offer a sorting functionality, it is designed to process data without any specific sorting requirements.</li><li>It is worth noting that the processOrder method may take slightly longer to execute when compared to the searchOrders method. However, the efficiency gains offered by this method when processing large numbers of orders (more than 1000) make it an excellent choice for batch processes and jobs.</li></ul><h3>Things to utilize while generating a query</h3><ul><li>When defining a query condition for an attribute, the identifier used must be the ID of the attribute as defined in the type definition. For custom-defined attributes, the search term must include the prefix ‘custom’ (e.g. custom.color = {1}), whereas, for system attributes, no prefix is required (e.g. name = {1}).</li><li>You have the option to include a sorting parameter in your query, which can consist of a comma-separated list of attribute names to sort your results by. Each attribute name can be followed by a sort direction specifier, such as ‘asc’ or ‘desc,’ with the default sorting direction being ascending if no direction is specified. Here’s an example of what the sorting parameter might look like: <strong>age desc, name.</strong></li><li>At present, it is not possible to use a localized custom attribute as the sorting attribute.</li><li>The following types of attributes are not queryable:<br>- <em>Image<br>- HTML<br>- Text<br>- Quantity<br>- Password</em></li><li>The following attribute value types are currently supported, along with some sample expression values:<br>- String: ‘String’, ‘Str*’, ‘Strin?’<br>- Integer: 1, 3E4<br>- Number: 1.0, 3.99E5<br>- Date: yyyy-MM-dd, e.g. 2007–05–31 (Default TimeZone = UTC)<br>- DateTime: yyyy-MM-dd’T’hh:mm:ss+Z, e.g. 2007–05–31T00:00+Z (Z TimeZone = UTC) or 2007–05–31T00:00:00<br>- Boolean: true, false<br>- Email: ‘<a href="/service/mailto:search@demandware.com">search@demandware.com</a>’, ‘*@demandware.com’<br>- Set of String: ‘String’, ‘Str*’, ‘Strin?’<br>- Set of Integer: 1, 3E4<br>- Set of Numbers: 1.0, 3.99E5<br>- Enum of String: ‘String’, ‘Str*’, ‘Strin?’<br>- Enum of Integer: 1, 3E4</li></ul><h3>Things to remember while using searchOrders or processOrders Method</h3><p>Avoid using the searchOrder methods or processing orders right after creating or updating an order. The order search index is updated asynchronously, usually within a few seconds, but sometimes it might take longer depending on the search service load. Therefore, recent changes might not be immediately reflected in the search index. Instead, consider either of the following approaches:</p><ol><li>If possible, pass the reference of the dw.order.Order object to the subsequent logic within the same request.</li><li>For storefront scenarios, particularly when sharing the order reference with a third party, prioritize security by using the order token and retrieving the order using the getOrder(String, String) method.</li></ol><h3>Did you know?</h3><h3>Everyone uses Google as a spellchecker.</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/728/1*w6r_KleCPk6Ux0IJk58Uyw.png" /></figure><p>Most everyone, anyway! 97% of people type in words to Google just to see if they spelled it right.</p><p>I know I’m definitely among that 97%!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1426d7c1a241" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Simple Guide to Use Source Code in Salesforce Commerce Cloud]]></title>
            <link>https://jatin29.medium.com/the-simple-guide-to-use-source-code-in-sfcc-6130f7e0dd86?source=rss-3bb25ea9590f------2</link>
            <guid isPermaLink="false">https://medium.com/p/6130f7e0dd86</guid>
            <category><![CDATA[sfra]]></category>
            <category><![CDATA[salesforce-commerce-cloud]]></category>
            <category><![CDATA[marketing]]></category>
            <category><![CDATA[demandware]]></category>
            <category><![CDATA[source-code]]></category>
            <dc:creator><![CDATA[Jatin Patel]]></dc:creator>
            <pubDate>Mon, 16 Jan 2023 06:21:53 GMT</pubDate>
            <atom:updated>2023-10-05T03:08:55.192Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*UPZXmSpumwerhKpgPz3EsA.png" /></figure><p>Welcome to my latest blog post on the topic of source code. As I was working on source code, I realized that it is an underutilized feature that many developers may not be fully aware of. That’s why I have decided to create a comprehensive guide on how to effectively use and configure source code in Salesforce Commerce Cloud (SFCC) to enhance your online marketing efforts. By the end of this post, you will have a clear understanding of the source code. Keep reading for all the details.</p><h3><strong>Table of Contents</strong></h3><ol><li>Purpose of source code</li><li>How to configure the source code</li><li>Source Code Site Preferences</li><li>How it works</li><li>Source code best practice</li><li>Source code dashboard</li></ol><h3><strong>Purpose of source code</strong></h3><p>Sources Codes are not new, but they’re often under utilized. They allow you to create a URL that directs visitors to any page on your Commerce Cloud site, such as a product detail page or category list. By utilizing the source code, you can alter the behavior of your site, such as</p><ol><li>By implementing a campaign with source code, these visitors can be presented with unique promotions, content sections, and sorting options.</li><li>Using the source code, it can apply a different price book to web site</li></ol><p>A source code is usually given to you by customers who found your website through an affiliate website or social media. It’s a very powerful but often overlooked tool for managing the traffic that comes from places like social media and emails.</p><h3><strong>How to configure the source code</strong></h3><p>In order to create a new source code group, navigate to <strong>Merchant Tools &gt; Online Marketing &gt; Source Code Groups</strong> in your account. Once there, you’ll find the option to create a new group. As you can see in the image below, it’s important to make sure the <strong>enabled</strong> flag is checked before you save your new source code. Once you’ve created your source code, you’ll be able to assign campaigns to it using the <strong>campaigns</strong> option.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iNhByqJmPC57jFOpRui3ug.png" /><figcaption>Source code-General Tab</figcaption></figure><p>After saving your new source code group, you will notice that other tabs become available. In the <strong>Codes </strong>tab, you have the ability to create an unlimited number of source codes for this group.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eTaoNhKL1TZfYLNhYy-Wkw.png" /><figcaption>Source code-Codes Tab</figcaption></figure><p>Once you’ve created your source code group and codes, the next tab to explore is the <strong>Redirects</strong> tab. Here, you can configure where users will be directed to when they access this source code. There are a few options to choose from, such as directing users to the homepage, a product detail page, a category landing page, or a custom URL. Additionally, there is a “default” option which will refer to the configuration set in <strong>Merchant Tools &gt; Site Preferences &gt; Source Codes</strong>. For more detailed instructions on how to set up these redirects, be sure to check out the section below(Source Code Site Preferences).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*R99zIK8lhsU02mJglBha-Q.png" /><figcaption>Source code-Redirects Tab</figcaption></figure><p>In the Price Books tab, where you can configure the price book that will be activated when a user navigates to your website using the source code URL and configured price book will be activated and shows price accordingly.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ms_C4LFFmIYoBg6j499Rzw.png" /><figcaption>Source code-Price Books Tab</figcaption></figure><h4>Attribute tabs</h4><p>If you have any specific business needs and want to extend the capabilities of the <strong>SourceCodeGroup </strong>system object, you can find it under Administration &gt; Site Development &gt; System Object Types. This will allow you to customize and add features to meet your business requirements. And any added attributes will be displayed in the attributes tab.</p><p>In summary, Source Code Groups allow you to group together one or more source codes that are handled in a similar manner by the storefront. These source codes can be literal codes or patterns that match multiple codes. By creating a source code group, you can apply the same set of rules, such as price books, promotions, and redirects, to multiple codes while still tracking the results on a per source code basis. Additionally, you can assign one or more source codes to a campaign, so that all promotions within that campaign use those specific source codes.</p><h3>Source Code Site Preferences</h3><p>Source codes are used by merchants to track customer activity and the origin of incoming visits to their storefront. Salesforce B2C Commerce’s source-code groups allow merchants to utilize this information for managing customer redirects, price books, and campaigns. The system’s site preferences allow merchants to specify how B2C Commerce should handle source codes.</p><ol><li>Select <strong>site </strong>&gt; <strong>Merchant Tools</strong> &gt; <strong>Site Preferences</strong> &gt; <strong>Source Codes.</strong></li><li>On the Source Code Preferences page, you can define defaults for handling source code preferences. For example, you can specify cookie duration, a standard redirect URL, and defaults for active and inactive redirects. Specify the following settings:</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*f4-nxYXOkkkwitTN_AVilQ.png" /><figcaption>site &gt; Merchant Tools &gt; Site Preferences &gt; Source Codes</figcaption></figure><p><strong>URL Parameter Name:</strong><br>The name of the source-code parameter on the URL query string.</p><pre>//Sample source code URL<br><br>http://user.dw.demandware.net/on/demandware.store/Sites-YourShopHere-Site/​default/​SourceCodeRedirect-Start?src=ABC</pre><p>In the above URL you will see the query string “?<strong>src</strong>=ABC”. You can configured any name for query string parameter.</p><p><strong>Cookie Duration in Days</strong><br>The duration in days that the source code is retained in a user’s session, which must be a value between 0 and 999.</p><p>This parameter is overridden if a cookie duration is specified for a specific source code group.</p><p><strong>Standard Redirect URL</strong><br>The URL designated for handling redirects will be displayed on the Codes tab of the specific source code group with the defined source code specification added.</p><p>It’s important to note that the same URL must be specified in the SEO section, where the connection to the actual redirect pipelet is defined.</p><p><strong>Active and Inactive Redirect Defaults<br></strong>If you have selected Defaults in the redirection tab for source code Group, It will pick the value of the redirect from this configuration.</p><h3>How it works</h3><p>When B2C Commerce receives a source code as a URL parameter, it validates the code by checking the existence, enabled status, start date, and end date of the source code group.</p><ul><li>If the source code is active and valid, B2C Commerce stores the current user session and the source code in a cookie.</li><li>If the source code isn’t active and valid, B2C Commerce ignores it and shows the normal landing page.</li></ul><pre>//Sample source code URL<br><br>http://user.dw.demandware.net/on/demandware.store/Sites-YourShopHere-Site/​default/​SourceCodeRedirect-Start?src=ABC</pre><p>The sample URL provided showcases the execution of the <strong>SourceCodeRedirect-Start</strong> route. This route reads the source code redirect URL information from the session and navigates the user to the corresponding URL. As the image below illustrates.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MSckjo_di1pCtrE8ECwy-A.png" /></figure><p>When a source code is configured to redirect to a product detail page, the system navigates to the <strong>Link-Product</strong> route instead of redirecting directly to the <strong>Product-Show</strong> page.</p><p>This action forms the proper URL and navigates to the final route. The same process applies for redirects to category landing pages or static pages. All of these methods can be found in the <strong>Link</strong> controller, as shown in the image below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*k7cm_BPnNoXV_-reGb9QFQ.png" /></figure><h4>Automatic Checks Performed by Frameworks</h4><ul><li>When it comes to B2C Commerce, the system has a specific process for handling source codes. If the system does not receive a source code in the URL, it will try to retrieve one from a stored cookie, assuming cookies are enabled. Once a source code is retrieved, it will be validated by the system. The length of time that the source code cookie is stored is determined by the cookie duration set for the specific source code group. In the event that no cookie duration is set for the source code group, the duration set in Business Manager site preferences will be used instead.</li><li>When multiple active source-code groups contain the same source code, B2C Commerce will default to using the group that was created most recently.</li><li>When a customer accesses the web site using the source code URL provided by the affiliate, the affiliate’s source code is activated. When the same customer exits the site, and then returns to it via another source code URL, a new source code replaces the previous one.</li></ul><h3><strong>Source code best practice</strong></h3><p>When it comes to creating source code for your project, there are a few best practices that you should keep in mind.</p><p><strong>Use Pattern<br></strong>When dealing with large amounts of source code, it is advisable to use a source code pattern rather than relying on individual source codes. This is particularly true if you require more than 100 source codes per source code group. Implementing a source code pattern will help to keep your code organized and make it easier to manage</p><p>When organizing your source codes, it can be helpful to group them into patterns. Here are a couple of examples of how this can be done:</p><ol><li>Utilize the SPRING* source-code specification to group all source codes that contain the word “SPRING” in the name, such as SPRINGOUTDOOR, SPRINGHOME, and SPRINGWOMENS, representing all Spring Sale catalogs.</li><li>Use patterns like OUTDOOR[N1..1000], HOME[N1..1000], and WOMENS[N1..1000] to group source codes. This would include all codes from OUTDOOR1 to OUTDOOR1000, HOME1 to HOME1000, and WOMENS1 to WOMENS1000, respectively.</li></ol><p>A source code group is a collection of source codes that are defined by a specific pattern. When the system processes a source code, it checks to see if the code matches the pattern of any defined source code groups. If a match is found, the corresponding source code group is activated and the code is associated with that group. It’s important to note that it’s not necessary to manually add each source code to a group, instead, the use of patterns should be the norm and only a small number of source codes should be added individually. The source code group pattern is used for identification but the actual code remains unchanged and is stored with the session.</p><p><strong>Check effective periods<br></strong>When utilizing source code groups as a qualifier, it is crucial to ensure that the dates of the source code group fall within the promotion schedule and that the group is enabled. This is because source code groups have their own effective period and a flag to indicate whether or not they are active. Failing to validate these factors could result in the source code group not being recognized during processing</p><p><strong>Form Proper URL<br></strong>B2C Commerce processes other source codes that belong to the same source code group in the same manner. If the URL contains a second source code parameter, such as:</p><pre>http://user.dw.demandware.net/on/demandware.store/Sites-YourShopHere-Site/​default/​SourceCodeRedirect-Start?src=ACME&amp;src=KATJA</pre><p>Then B2C Commerce only evaluates the first parameter and ignores the second.</p><p>Because only one source code group can be active at a time, B2C Commerce considers source codes that belong to different source code groups to be inactive. These source codes can be mapped in a similar manner, but to a different product, category, page or URL.</p><p><strong>Price book assignment<br></strong>It is important to note that when creating a price book, it should not be assigned to a specific site, as this will cause it to function as a regular price book. Instead, the price book should not have any site assignments, so that it can be used as intended.</p><p><strong>Characters limit<br></strong>The maximum length of Source code group IDs has been reduced to 28 ASCII characters. This applies to both source codes created using the Business Manager Source Code Creation page and those imported. If an attempt is made to create a source code with more than 28 characters an error message will appear indicating the character limit. In the past, source codes that exceeded the limit were truncated.</p><h3><strong>Source Code Dashboard</strong></h3><p>Analytics can help you understand the impact of promotions that are qualified by source codes. These reports are primarily utilized by the merchandising team.</p><p>To access the Reports &amp; Dashboards Promotions Source Code Dashboard, Select <strong>Merchant Tools</strong> &gt; <strong>site</strong> &gt; <strong>Analytics</strong> &gt; <strong>Reports &amp; Dashboards</strong>. Select the <strong>Promotions</strong> tab, and select the <strong>Source Code</strong> tab.</p><p>The Promotions Source Code Dashboard is a single point source for all source code data.</p><p>You can use the dashboard to view source code conversion activity, and to determine which campaigns are driving orders and revenue in your storefront.</p><p>The dashboard has three reports.</p><ul><li>Source Code Activations : Order conversion by source code classification.</li><li>Order Conversion Results : All visits having at least one source code</li><li>Conversion of Source Codes : source code activations that created at least one order.</li></ul><p>You can use the dashboard date range and filters settings to create a custom view of the metrics. You can filter the dashboard by site, device type (desktop, phone, tablet, unknown or unrecognized), and customer registration (registered or unregistered). Depending on your business needs, you can also download the metrics for each report as a csv file.</p><p>The following definitions will assist you in creating reports using Dashboards.</p><p><strong>Source Code</strong>: A code provided by a redirect link.<br><strong>Activation</strong>: The initiation of a source code when a customer clicks a redirect link that includes the source code.<br><strong>Active Source Code</strong>: A source code that is known and active.<br><strong>Inactive Source Code</strong>: A source code that is known but not currently active.<br><strong>Invalid Source Code</strong>: A source code that is unknown to the system.<br><strong>ATC Rate</strong>: Add-to-Cart Rate measured as Add-to-Cart/Clicks.</p><p>I hope this information on source code has been helpful and informative. Understanding the creation and usage of source code, as well as the best practices surrounding it, is important. If you have any personal experiences or insights on strange source code issues and how they were resolved, please share them in the comments section. Your input would be greatly appreciated by the Salesforce Commerce Cloud community. Thank you for reading.</p><p>I am eagerly anticipating your valuable feedback and insights, which you can share with me either here or on <a href="https://linkedin.com/in/jatin291192"><strong>LinkedIn</strong></a>. Your comments are greatly appreciated and will help me to continually improve and enhance my understanding and capabilities. Thank you in advance for taking the time to share your thoughts and insights with me.</p><h4>Did you know?</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/728/1*ZHNnH4Ft7Po4fgAghNggrg.png" /><figcaption>domains</figcaption></figure><p><strong>Domain name registration used to be free</strong></p><p>In the early days of the internet, registering a domain name was a free service until 1995. However, as the internet began to grow in popularity and importance, a fee was introduced for registration. Initially, the cost of registering a domain name was quite high, with prices typically around $100 for a two-year registration.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6130f7e0dd86" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Code/Data Replication Best Practices in Salesforce Commerce Cloud]]></title>
            <link>https://jatin29.medium.com/code-data-replication-best-practices-in-storefront-reference-architecture-d60f576e3176?source=rss-3bb25ea9590f------2</link>
            <guid isPermaLink="false">https://medium.com/p/d60f576e3176</guid>
            <category><![CDATA[replication]]></category>
            <category><![CDATA[demandware]]></category>
            <category><![CDATA[blog]]></category>
            <category><![CDATA[salesforce-commerce-cloud]]></category>
            <category><![CDATA[sfra]]></category>
            <dc:creator><![CDATA[Jatin Patel]]></dc:creator>
            <pubDate>Fri, 06 Jan 2023 14:45:41 GMT</pubDate>
            <atom:updated>2023-10-05T03:07:48.025Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eZ-So5VFPaq7ANN5OSrDPg.jpeg" /></figure><p>Welcome to our latest blog post on replication! In this post, we will explore the steps to take before replicating, particularly in production environments. We’ll also cover how to troubleshoot any errors that may arise during the process. Keep reading for all the details.</p><h3><strong>Table of Contents</strong></h3><ol><li>Replication best practices</li><li>Pre-replication steps to ensure smooth execution</li><li>Items that cannot be replicated</li><li>Debugging replication issues</li></ol><h3>Replication Best Practices</h3><p>To ensure a error-free and smooth replication process, it’s important to follow some best practices. Here are a few to keep in mind:</p><ol><li>To ensure a smooth replication process, it’s best to follow a specific workflow. First, replicate your staging instance to a development instance and verify the results. If any changes are necessary, make them on your staging instance and repeat the replication process. Once you’ve confirmed that everything is correct on the development instance, you can safely replicate from staging to production.</li><li>To avoid any issues during the replication process, it’s important to avoid making manual changes in Business Manager on either the source or target instances while replication is running. Additionally, make sure to halt any ongoing jobs on the target instance before beginning replication.</li><li>To avoid potential conflicts, it’s best to avoid running multiple replication processes concurrently.</li><li>When modifying a system object type, it’s recommended to replicate global system object types first before replicating any objects of that type. This will help ensure a smooth replication process.</li><li>To avoid data corruption, it’s crucial to identify and respect the dependencies between different data replication groups. For example, if you have campaigns that rely on source codes and coupons, be sure to replicate these items before or alongside campaigns. Failing to do so can result in data corruption.</li><li>It’s important to keep in mind that replication processes can be resource-intensive and may impact site performance. To minimize any negative effects, it’s best to run replications during periods of low traffic, such as late at night or early in the morning. When replicating to production, schedule the process for a time when storefront activity is at a minimum. Additionally, try to avoid major data replications during Salesforce B2C Commerce’s standard maintenance windows.</li><li>As part of the replication process, the page cache is automatically cleared. To avoid any issues, do not manually clear the page cache again.</li><li>It’s generally best practice to avoid making direct code or cartridge path edits in a production instance. This can lead to unexpected results, such as multiple versions of pages. To ensure that your code and preferences are consistent in production, <strong>always replicate from your staging instance to production</strong>.</li><li>It’s worth noting that you can only roll back the most recent data or code replication. For instance, you can’t undo a code replication and then revert the previous code replication. However, data and code replications do not impact each other’s rollback capabilities. For example, if you replicate data followed by code, you can still undo the data replication, and the same goes for code replications.</li></ol><h3>Pre-replication steps to ensure smooth execution</h3><p>Before replicating code or data, especially from the stage to production, it’s important to consider the following:</p><ol><li>It’s a good idea to check if any jobs are currently running on that instance. If there are, you should wait for them to be completed before proceeding with the replication process.</li><li>it’s important to check if there are any current data or code replications happening. If there are, you may need to wait until they are completed.</li><li>Avoid making any manual changes to the object that is being replicated. for example, if you are replicating the catalog, don’t make any manual changes to the catalog in the target instance.</li><li>If your code depends on data, make sure to replicate the data first.</li></ol><h3>Items that cannot be replicated</h3><p>There are certain types of data that cannot be replicated using the data replication feature. You need to create or import this type of data using XML on your development and production instances. Here below is the list which we can not replicate</p><ul><li>Active data</li><li>Batch processes</li><li>Catalog and content import feeds</li><li>Custom error pages</li><li>Customers and customer group assignments</li><li>Files that are uploaded but not imported</li><li>Gift certificates</li><li>Inventory data</li><li>Job schedules and history</li><li>Organization profile</li><li>Payment information</li><li>Order information (for example, tax and shipping)</li><li>Sitemaps</li><li>Source Code redemptions</li><li>Users, roles, and permissions</li></ul><h3>Debugging replication issues</h3><p>To monitor the status of your code or data replication, go to <strong>Administration &gt; Replication &gt; Code Replication</strong> or <strong>Administration &gt; Replication &gt; Data Replication</strong>. If you see a failed status, you’ll need to troubleshoot the issue by looking at the replication logs.</p><h4><strong>How to Access Replication Logs in Your System</strong></h4><p>During the replication process, log files are generated on both the source and target systems and can be accessed separately from the regular error logs. To view these log files in the file system,</p><ol><li><a href="https://instance_address/on/demandware.servlet/webdav/Sites/Logs/">https://instance_address/on/demandware.servlet/webdav/Sites/Logs/</a> navigate to above link and the log files will have filenames like <strong>staging-blade_name-appserver-yyyymmdd.log</strong>.</li><li>Alternatively, you can view the log files in Business Manager by going to <strong>Administration &gt; Site Development &gt; Development Setup &gt; Log Files</strong> Again, the log files will have filenames like staging-blade_name-appserver-yyyymmdd.log.</li></ol><p>Note that all log file names contain <strong>staging</strong>, regardless of the instance type.</p><h4>Things to check when replication takes longer time than expected</h4><p>Some database transactions, particularly those that involve large amounts of data, can take longer to complete. If you notice that your replication is taking longer than expected, it’s possible that it could be hung.</p><p>If you are having issues with the replication process, one thing you can try is checking the replication log on the staging/target instance. Here’s how:</p><p>Open the most recent replication log file on the staging instance.</p><ol><li>Look for the line “<strong>Staging pipeline in live system successfully called”</strong>. If this line is not present in the log file, it could indicate that there is a problem with the replication process.</li><li>Check for an entry stating that a state is set to <strong>ErrorAcquiringEditingLocks</strong>. If this is present in the log file, it’s possible that resource locks from a previous replication process were not released, which could cause the current replication to hang.</li></ol><p>Open the most recent replication log file on the target instance, and scroll to the end.</p><ol><li>Refresh the log files a few times to see if new entries are being added to the log. If no new entries appear after a while, it’s possible that the replication is hung.</li><li>Check the log for an entry stating that the state is set to <strong>ErrorLiveStagingProcessKilled</strong>. If this is present, the replication may be hung due to a concurrent deployment or instance restart.</li><li>If the last log entry starts with <strong>Rsync</strong>, the delay may be due to a large number of changed static content files. Even if their content is the same, files that have been moved to a different folder will be included in the replication process. If the Rsync appears to be stuck, you can contact support to check its status.</li></ol><p>If you come across a line in either log that mentions “<strong>resource busy and acquire with NOWAIT specified”</strong>, it’s time to contact Support. When you open a ticket, be sure to include any troubleshooting steps you’ve already tried.</p><p>If the replication process is showing as completed on the target instance but is still waiting or in progress on the staging instance, take a look at the staging instance. It’s possible that it was down when the replication finished. To fix the issue, try restarting the staging instance and then check the status again.</p><h4>Steps to resolve replication hung issue</h4><ol><li>If you’re experiencing replication hang-ups, try using Control Center to restart the staging instance. Once the restart is complete, check to make sure that the hung replication has stopped and its status is now <strong>Failed.</strong> From there, you can try rerunning the replication.</li><li>If that doesn’t work, you may want to try restarting both the target and source instances, followed by rerunning the replication. However, it’s important to note that restarting the target instance can disrupt any running jobs, cause errors for storefront requests, and clear any caches. This should only be done as a last hope, especially if the target instance is a production instance.</li><li>If you’re still having trouble, don’t hesitate to reach out to customer Support for assistance. Make sure to include details about the troubleshooting steps you’ve tried so far.</li></ol><h4>Post-Replication Issue</h4><p>Here are some steps you can follow if you experience an issue after replicating data:</p><ol><li>Check the replication logs on both the staging and target instances for error messages. Pay particular attention to any entries that include the word <strong>failed</strong>.</li><li>If the logs don’t give you any clues, try checking the error logs on a log center.</li><li>If you’re experiencing issues with the replication of multiple objects, try replicating individual objects to help narrow down the cause.</li><li>If a scheduled replication hasn’t run as expected, try running it manually to see if that resolves the issue.</li></ol><p>If you have any experiences with strange replication issues and how you were able to fix them, please feel free to share them in the comments — it would be helpful for the entire Salesforce Commerce Cloud community. Thank you for reading!</p><h3>Interesting fact about the Technology</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/0*bKiTR87yrS0LcP1p.jpg" /></figure><p><strong>350,000 tweets are sent per minute.</strong></p><p>Every second, on average, around 6,000 tweets are tweeted on Twitter, which corresponds to over 350,000 tweets sent per minute, 500 million tweets per day and around 200 billion tweets per year.</p><p>I am eagerly anticipating your valuable feedback and insights, which you can share with me either here or on <a href="https://linkedin.com/in/jatin291192">LinkedIn</a>. Your comments are greatly appreciated and will help me to continually improve and enhance my understanding and capabilities. Thank you in advance for taking the time to share your thoughts and insights with me.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d60f576e3176" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Maximizing Efficiency with the Chunk Oriented Script Module in the Job Framework for Salesforce…]]></title>
            <link>https://jatin29.medium.com/maximizing-efficiency-with-the-chunk-oriented-script-module-in-the-job-framework-for-storefront-80145fe375a9?source=rss-3bb25ea9590f------2</link>
            <guid isPermaLink="false">https://medium.com/p/80145fe375a9</guid>
            <category><![CDATA[demandware]]></category>
            <category><![CDATA[sfra]]></category>
            <category><![CDATA[jobs]]></category>
            <category><![CDATA[sfcc]]></category>
            <category><![CDATA[chunkorientedsctip]]></category>
            <dc:creator><![CDATA[Jatin Patel]]></dc:creator>
            <pubDate>Sun, 01 Jan 2023 07:51:51 GMT</pubDate>
            <atom:updated>2023-10-05T03:07:17.814Z</atom:updated>
            <content:encoded><![CDATA[<h3>Maximizing Efficiency with the Chunk Oriented Script Module in the Job Framework for Salesforce Commerce Cloud</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6zJLP7A0TEKEVoBDQuOESg.jpeg" /></figure><p>Before discussing the chunk-oriented script custom job, let’s review the different types of custom job scripts that can be created in the SFRA. There are two approaches available:</p><ol><li>Task-Oriented Script</li><li>Chunk-Oriented Script</li></ol><p><strong>Task-oriented scripts</strong> are scripts that are designed to perform a specific task or set of tasks. These scripts are typically run as one-time processes and are used to perform tasks such as data migration, data cleansing, or other types of data manipulation.</p><p><strong>Chunk-oriented scripts</strong> are scripts that are designed to process a large amount of data in smaller chunks, rather than all at once. These scripts are typically used when the data being processed is too large to be processed all at once, or when the task being performed requires that the data be processed in smaller chunks for performance or other reasons.</p><h4><strong>Task-Oriented Script</strong></h4><p>It is common for developers to only be familiar with task-oriented script modules, as most jobs are created using this type of module. In a task-oriented script module, a specific function is designated as the main function for the job step and its name is listed in the steptypes.json file.</p><p>The steptype.json file specifies the main function for a job step. In the example shown below, the main function is called “myFunctionName” and it is located in the “MyModule.js” file. This function serves as the starting point for any logic or execution within the job step. Simple !!!!😎 everyone knows about it and we will not delve deeper into it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/809/1*7hsVa6mm4wT70-XogjVu_w.png" /><figcaption>sample <strong>steptype.json</strong> for task oriented script module</figcaption></figure><h4>Chunk-Oriented Script</h4><p>Now, let’s closely examine the chunk-oriented script module and how it differs from the task-oriented script module. Before we start with the chunk-oriented script module, let’s make a list of our questions. Once we have answers to these questions, it will clarify most of the concepts related to the chunk-oriented script. We will discuss the following topics:</p><ul><li>How does the chunk-oriented script module differ from the task-oriented script module?</li><li>When should we use one or the other?</li><li>How do we implement and execute chunk-oriented scripts?</li></ul><p><strong>How does the chunk-oriented script module differ from the task-oriented script module?</strong></p><p>A task-oriented script execution starts with the main function which is the entry point for all the operations such as fetching data, processing it, and writing it will be done by a single executable function, although it can also be broken up into smaller internal functions for better organization and modularity. However, it will not be managed by the job framework.</p><p>On the other hand, a chunk-oriented script is a script that is designed to perform a specific operation in a larger process. For example, a chunk-oriented script’s function might be responsible for fetching data, while another function is responsible for processing that data, and a third function is responsible for writing it back. Each of these scripts is a “chunk” of the overall process, and they are typically managed by a job framework that coordinates their execution. This allows for greater flexibility and scalability, as each function can be run independently or in combination with others as needed. We will discuss about all the functions in details in below section.</p><p>To return a specific status code, the task-oriented script module’s function can return a dw.system.Status object. This object allows you to specify the exit status code and an optional message that will be logged.<br>For example, you could use the following code to return an OK status with a custom message:</p><pre>return new dw.system.Status(dw.system.Status.OK, &quot;This is a OK message&quot;);</pre><p>Alternatively, if you want to return an ERROR status, you can throw an exception or return a Status object with the error flag set to true. For example:</p><pre>return new dw.system.Status(dw.system.Status.ERROR, &quot;This is an error message&quot;);</pre><p>It’s important to note that the task oriented script module’s function should always return a Status object or throw an exception to control the exit status. If the function finishes without returning a Status object or does not throw an exception, the exit status will be OK by default.</p><p>We can’t define the exit status for a chunk-oriented script module. Chunk modules always finish with either OK or ERROR. if you want to break the job, need to throw an error(This is a Hack!! 😎).</p><p><strong>When should we use chunk-oriented script?</strong></p><p>Both task-oriented and chunk-oriented scripts can be useful in different scenarios, depending on the needs of the project. It’s important to carefully consider the requirements of the task at hand and choose the appropriate type of script to ensure the most efficient and effective solution.</p><p>It is generally a good idea to use a chunk-oriented script when processing large amounts of data, as it allows you to break the processing into smaller chunks or batches, which can make the task more manageable and more efficient. This is especially true when you are dealing with very large datasets, as a single task-oriented script may not be able to process all of the data in a reasonable amount of time, or may run into issues such as timeouts or memory errors.</p><p>When we have to process a large amount of data and export millions of profiles, products, or orders, it’s better to use a chunk-oriented script. This type of script has a separate function for different operations and allows you to define the chunk size.</p><p>In addition to the benefits mentioned above, using a chunk-oriented script can also help to reduce the impact of the processing on other systems and resources, as it allows you to spread out the workload over a longer period of time rather than performing all of the processing at once. This can be especially important in environments where resources are limited.</p><p><strong>How do we implement and execute chunk-oriented scripts?</strong></p><p>To configure a chunk-oriented script, we need to create a file called “steptype.json” and define several functions inside it, such as the read-function, write-function, and process function(As shown in below image). These functions will be invoked and executed at specific times. Let’s now discuss the purpose of each function(most commonly used) and when it will be called.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/841/1*4Jh-eUXo36P4cxyqi-_PKw.png" /><figcaption>sample <strong>steptype.json</strong> for chunk oriented script module</figcaption></figure><p><strong>“read-function”</strong></p><p>The read function is an optional element of the steptype.json configuration however, it must be defined in the script file otherwise if will throw an error. If it is not defined in the steptype.json file, the script must include a function called <strong>read</strong> to serve as the read function. it returns a single item or nothing if there are no more items to be processed.</p><p><strong>“process-function”</strong></p><p>The process function is similar to the read function in that it is optional in the steptype.json configuration however, it must be defined in the script file otherwise if will throw an error. If it is not defined in the steptype.json file, the script must include a function called <strong>process</strong> to serve as the process function.</p><p>The process function transforms items and applies business logic to them. It takes an item returned by the read function, performs a process on it, and returns a single item as output. This output item can be the same as the input item if no processing is necessary, or it can be a different type of item. If the process function returns nothing, the item returned by the read function will be filtered and will not appear in the list of items to be written later.</p><p><strong>“write-function”</strong></p><p>The write function is similar to the read function/process function in that it is optional in the steptype.json configuration however, it must be defined in the script file otherwise if will throw an error. If it is not defined in the steptype.json file, the script must include a function called <strong>write</strong> to serve as the write function.</p><p>The write function receives a list of items as input. The size of this list will match the chunk size, or it may be smaller if the number of items in the last available chunk is smaller. it does not return anything.</p><p><strong>“before-step-function”</strong></p><p>The before-step function in a chunk-oriented script module is invoked before the step begins. If this function is not defined, no before-step logic will be used.</p><p><strong>“after-step-function”</strong></p><p>The after-step function is similar to the before-step function in that it is a part of the chunk-oriented script module. However, it is executed after the steps are completed. If this function is not defined, no after-step logic will be used.</p><p><strong>“before-chunk-function”</strong></p><p>The before-chunk function in a chunk-oriented script module is invoked before a chunk begins. If this function is not defined, no before-chunk logic will be used.</p><p><strong>“after-chunk-function”</strong></p><p>The after-chunk function is similar to the before-chunk function in that it is a part of the chunk-oriented script module. However, it is executed after the steps are completed. If this function is not defined, no after-chunk logic will be used.</p><p><strong>“total-count-function”</strong></p><p>The total count function returns the total number of items that are available for processing. It is called by the framework once before chunk processing starts. Knowing the total count can be useful for monitoring progress, such as showing that 50 out of 100 items have been processed.</p><p>In addition to the functions discussed, there are also important attributes to consider in a chunk-oriented script. Let’s delve into these in more detail.</p><p><strong>“supports-organization-context”</strong></p><p>The attribute supports-organization-context must be set to either true or false. The default value is true. If it is set to true, steps of this type can be used in flows with an organization scope. If it is set to false, steps of this type cannot be used in flows with an organization scope.</p><p>The attribute supports-site-context cannot have the same value as supports-organization-context. If supports-site-context is false, supports-organization-context must be true and vice versa.</p><p><strong>“supports-parallel-execution”</strong></p><p>The attribute supports-parallel-execution must be set to either true or false. The default value is true. If it is set to false, split flows that include steps of this type will always be executed sequentially and never in parallel. If it is set to true, split flows that include steps of this type will be executed in parallel, as long as the following conditions are met:</p><ul><li>The split flows do not contain steps with supports-parallel-execution set to false.</li><li>The split flows are not configured to be executed sequentially.</li><li>There are sufficient resources available for parallel execution.</li></ul><p><strong>“chunk-size”</strong></p><p>Chunk size is a numeric value that specifies the size of each chunk. It must not have any leading or trailing white space.</p><p><strong>“transactions”</strong></p><p>The attribute transactions indicates whether the module requires a database transaction. It must be set to either true or false. The default value is false. If this value is set to true, the job step will execute as a single, potentially large, transaction. It is recommended to keep the default value of false to avoid negatively impacting system performance and to enable more granular transaction control. Instead, transaction handling can be implemented within the job step using the dw.system.Transaction API.</p><p>Now let’s examine a sample code to see how the various functions can be defined in a chunk-oriented script job.</p><pre>var system = require( &#39;dw/system&#39; );<br>var catalog = require( &#39;dw/catalog&#39; );<br>var job = require( &#39;dw/job&#39; ); <br>var io = require( &#39;dw/io&#39; );<br><br>var products;<br>var fileWriter;<br> <br>exports.beforeStep = function( parameters, stepExecution )<br>{<br>  fileWriter = new io.FileWriter( new io.File( io.File.IMPEX ), parameters.ExportFileName );<br>  products = catalog.ProductMgr.queryAllSiteProducts();<br>  fileWriter.writeLine( &quot;&lt;products&gt;&quot; );<br>}<br> <br>exports.getTotalCount = function( parameters, stepExecution )<br>{<br>  return products.count;<br>}<br><br><br>exports.read = function( parameters, stepExecution )<br>{<br>  if( products.hasNext() )<br>    {<br>    return products.next();<br>    }<br>}<br> <br>exports.process = function( product, parameters, stepExecution )<br>{<br>  if( product.isOnline() )<br>  {<br>    return &quot;&lt;product&gt;&quot; + product.getID() + &quot;&lt;/product&gt;&quot;;<br>  }<br>}<br> <br>exports.write = function( lines, parameters, stepExecution )<br>{<br>  for ( i = 0; i &lt; lines.size(); i++ ) <br>  {<br>    fileWriter.writeLine( lines.get(i) );<br>  }<br>} <br> <br>exports.afterStep = function( success, parameters, stepExecution )<br>{<br>  if( success )<br>  {<br>    fileWriter.writeLine( &quot;&lt;/products&gt;&quot; );<br>  }<br>  fileWriter.close();<br>  products.close();<br>}</pre><p>Now, let’s use an example to understand how the chunk processing works and when each function is invoked.</p><p>As an example, consider a chunk-oriented job that needs to process 11 products with a chunk size of 4. The defined read, process, and write functions will be called in the sequence shown in the table below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/413/1*-MPclqApWtLd4ec81d4hng.png" /></figure><p>For the final chunk, the read, process, and write functions will handle fewer items than the previous chunks, as there are only three items remaining on the list.</p><p>In summary, chunk-oriented script modules are useful for processing large amounts of data. You should now have a basic understanding of how to use and configure chunk-oriented scripts.</p><p>It is possible to create job step configurations using both JSON and XML. Please let us know in the <strong>comment section </strong>which file extension you prefer for configuring your job and why. Additionally, please share any difficulties you have experienced using either JSON or XML.</p><h4>Interesting fact about the Technology</h4><p>The name Google was created accidentally, it was originally supposed to be named ‘<strong>Googol</strong>’. <em>(Googol is the digit 1 followed by 100 zeroes).</em></p><p>The founders checked to see if that domain name was taken, but accidentally searched for ‘google.com’ instead of ‘googol.com’. They liked that name even better and registered the domain name on September 15, 1997.</p><p>I am eagerly anticipating your valuable feedback and insights, which you can share with me either here or on <a href="https://linkedin.com/in/jatin291192">LinkedIn</a>. Your comments are greatly appreciated and will help me to continually improve and enhance my understanding and capabilities. Thank you in advance for taking the time to share your thoughts and insights with me.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=80145fe375a9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[mockCall and mockFull callbacks in services of Salesforce Commerce Cloud]]></title>
            <link>https://jatin29.medium.com/mockcall-and-mockfull-callback-in-service-call-in-salesforce-commerce-cloud-e2e7b46b9649?source=rss-3bb25ea9590f------2</link>
            <guid isPermaLink="false">https://medium.com/p/e2e7b46b9649</guid>
            <category><![CDATA[sfra]]></category>
            <category><![CDATA[development]]></category>
            <category><![CDATA[demandware]]></category>
            <category><![CDATA[sfcc]]></category>
            <category><![CDATA[mockservice]]></category>
            <dc:creator><![CDATA[Jatin Patel]]></dc:creator>
            <pubDate>Fri, 23 Dec 2022 10:00:53 GMT</pubDate>
            <atom:updated>2023-10-05T03:06:43.391Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2x7337F_6VBzATqUjJvziQ.png" /><figcaption>A beautiful Jispa village, Himachal Pradesh</figcaption></figure><h4>How I thought to write about mock service.</h4><p>While working with one of the 3rd party integration, I have to make an API call to fetch the data. However, they do not have API for the lower environment and they have only production API. So, every time we can not make a production API call since it generates dummy data on the production instance. In that scenario, a mock service call will be a savior for developers to continue their work without worrying about external service calls.</p><h4>Purpose of mock service</h4><p>There are server use cases of mock service as listed below</p><ul><li>The most common and crucial use case is to test the service without making an actual service call.</li><li>When you have only production API and you don’t want to make live API call.</li><li>Sometimes the service API is not responding or the server is down and you are unable to make a service call. so, without interruption of development, you can continue with a mock service call.</li></ul><p>We can enable service mode <strong>mocked</strong> and add mockCall or mockfFull attribute to the service callback. Now, we have a below question in our mind.</p><h4><strong>What is the difference between mockCall and mockFull callbacks?</strong></h4><p>The callbacks contain code that is executed at appropriate times by the service framework. For example, an HTTP or FTP service instance typically implements three callbacks: createRequest, parseResponse, and mockCall (if we enable service mode <strong>mocked</strong>).</p><p>In case of an actual service call the callback function called in the below sequence</p><ul><li>createRequest</li><li>Make an actual service call and return the response</li><li>parseResonse</li></ul><p><strong>mockCall:</strong></p><p>If we have mocked the service and implemented the mockCall function then the callback function is called in the below sequence</p><ul><li>createRequest</li><li>mockCall</li><li>parseResonse</li></ul><p>So basically, the mockCall functions override the method to mock the remote portion of the service call. Other callbacks like createRequest and parseResponse are still called.</p><p><strong>mockFull:</strong></p><p>If we have mocked the service and implemented the mockFull function then it overrides to mock the entire service call, including the createRequest, execute, and parseResponse callbacks.</p><h4>How to enable mock service</h4><p>Go to Administration &gt; Operations &gt; Services in the business manager, open the service which you want to mock and change the service mode from Live to Mocked(as shown in the below image)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/815/1*vIUDQrDkUeZrJ2jBaIDBxA.png" /><figcaption>Service detail page in BM</figcaption></figure><p>Now, we need to create a callback function in the code. If we have a mockFull and mockCall both the callbacks in the service, It always executes the mockFull callback. So If we want to execute mockCall callback then we need to remove mockFull callback from the code.</p><pre>LocalServiceRegistry.createService(&quot;xxx.mocked.api&quot;, {<br>        createRequest: function (svc, param) {<br>            if (param) {<br>                return JSON.stringify(param);<br>            }<br>            return null;<br>        },<br>        parseResponse: function (svc, response) {<br>            if (response.statusCode === 200) {<br>                return {<br>                    statusCode: response.statusCode,<br>                    statusMessage: response.statusMessage,<br>                    text: JSON.stringify(response.text)<br>                }<br>            }<br>            return {<br>                error: true<br>            };<br>        },<br>        filterLogMessage: function (msg) {<br>            return msg;<br>        },<br>        mockCall: function (svc, params) {<br>            return {<br>                    statusCode: 200,<br>                    statusMessage: &#39;success&#39;,<br>                    text: &#39;{test: response}&#39;<br>                }<br>           // return the response object which will pass to the parseResponse callback<br>        },<br>        mockFull: function (params) {<br>          // return the response object which will directly return to the caller methor with out going to parseResponse callback<br>        }<br>    });</pre><h4>Conclusion</h4><p>Now that you’ve read this post, you know exactly how to mock a service.<br>So, What’s Next?<br>Go and use this mock callback when you want to test the service without making an actual call.</p><h4>Interesting fact about the Technology</h4><p>Every advertisement for an Apple iPhone, the time will be set as 9:41. This is the time that Steve Jobs announced the very first iPhone in 2007.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/0*XOByrXOOglxljCZR.png" /><figcaption>iPhone Image</figcaption></figure><p>As always, looking forward to your comments either here or on <a href="https://linkedin.com/in/jatin291192">LinkedIn</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e2e7b46b9649" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Use of “server.use” in B2C Salesforce Commerce Cloud]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://jatin29.medium.com/use-of-server-use-in-storefront-reference-architecture-acc8eba29e2e?source=rss-3bb25ea9590f------2"><img src="https://cdn-images-1.medium.com/max/1024/1*BJtzi23FBB0oYzlymPMVhg.png" width="1024"></a></p><p class="medium-feed-snippet">While working on the integration of the 3rd party functionality, I came across one of the scenarios where I learned one of the use cases&#x2026;</p><p class="medium-feed-link"><a href="https://jatin29.medium.com/use-of-server-use-in-storefront-reference-architecture-acc8eba29e2e?source=rss-3bb25ea9590f------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://jatin29.medium.com/use-of-server-use-in-storefront-reference-architecture-acc8eba29e2e?source=rss-3bb25ea9590f------2</link>
            <guid isPermaLink="false">https://medium.com/p/acc8eba29e2e</guid>
            <category><![CDATA[demandware]]></category>
            <category><![CDATA[salesforce-commerce-cloud]]></category>
            <category><![CDATA[sfcc]]></category>
            <category><![CDATA[sfra]]></category>
            <category><![CDATA[developement]]></category>
            <dc:creator><![CDATA[Jatin Patel]]></dc:creator>
            <pubDate>Thu, 15 Dec 2022 07:18:01 GMT</pubDate>
            <atom:updated>2023-10-05T03:05:54.208Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Dil Ki Baat….“Me jo hu vahi rahene do muje”]]></title>
            <link>https://jatin29.medium.com/dil-ki-baat-me-jo-hu-vahi-rahene-do-muje-d6b9957e3b0b?source=rss-3bb25ea9590f------2</link>
            <guid isPermaLink="false">https://medium.com/p/d6b9957e3b0b</guid>
            <category><![CDATA[poerty]]></category>
            <category><![CDATA[dil]]></category>
            <category><![CDATA[poet]]></category>
            <category><![CDATA[selfloving]]></category>
            <category><![CDATA[nature]]></category>
            <dc:creator><![CDATA[Jatin Patel]]></dc:creator>
            <pubDate>Mon, 14 Sep 2020 06:31:20 GMT</pubDate>
            <atom:updated>2020-09-14T06:31:20.023Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*51dOMcdXyM5ckcX5c3NN-A.jpeg" /></figure><h3><strong>मे जो हु वही रहने दो मुझे</strong></h3><p>एक दिल की बात कहेने दो मुझे<br>आज़ाद हवा मे बहेने दो मुझे<br>क्यूँ बनु मे औरो की तरह,<br>अब मे जो हु वही रहने दो मुझे.</p><p>बादलो के संग उड़ने दो मुझे<br>बारिश की बूंदो सा निचे उतरने दो मुझे<br>हाथो की लकीरो के सहारे बहोत जी लिया,<br>अब महेनत से लकीरे खींचने दो मुझे</p><p>घटा, फ़िज़ा वादीओ मे टहलने दो मुझे<br>जीवन का सार भागवत गीता से पिने दो मुझे<br>सब अपने मतलब की बातें करते है,<br>अब बिन बोले दिल की बातें करने दो मुझे</p><p>अपने पर खोलने दो मुझे<br>खुद से खुद को मिलने दो मुझे<br>बहोत भाग लिया शोहरत के पीछे,<br>अब सुकून की नींद सोने दो मुझे</p><p>आसमान में खो जाने दो मुझे<br>समंदर में डूब जाने दो मुझे<br>दरिंदगी के कीचड़ में अब,<br>खूबसूरती का कमल खिलाने दो मुझे</p><p>दिल की बात दिल से करने दो मुझे<br>खिलोनो के संग खेलने दो मुझे<br>बहोत जी लिया MOBILE के संग<br>अब मेरा बचपन जीने दो मुझे</p><p>कच्ची धुप में पकने दो मुझे<br>महेनत से लोहा बनाने दो मुझे<br>क्यूँ बनु मे औरो की तरह<br>अब मे जो हु वही रहने दो मुझे</p><p>Our previous post : <a href="https://medium.com/@jatin291192/before-lockdown-vs-after-lockdown-a89e02d7fa39">Before Lockdown vs After Lockdown</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d6b9957e3b0b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Before Lockdown vs After Lockdown]]></title>
            <link>https://jatin29.medium.com/before-lockdown-vs-after-lockdown-a89e02d7fa39?source=rss-3bb25ea9590f------2</link>
            <guid isPermaLink="false">https://medium.com/p/a89e02d7fa39</guid>
            <category><![CDATA[funny]]></category>
            <category><![CDATA[lockdown]]></category>
            <category><![CDATA[quotes]]></category>
            <category><![CDATA[shayari]]></category>
            <category><![CDATA[poetry]]></category>
            <dc:creator><![CDATA[Jatin Patel]]></dc:creator>
            <pubDate>Thu, 03 Sep 2020 08:32:05 GMT</pubDate>
            <atom:updated>2020-09-03T08:42:28.176Z</atom:updated>
            <content:encoded><![CDATA[<p>These below lines show how things changed before lockdown and after lockdown. I have tried to present it in a funny way…<br>Hope you guys liked it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IB1T2tR5L2nB8srI3QUqzA.jpeg" /><figcaption>think out of the box</figcaption></figure><h3><strong>..वो आज</strong></h3><p>100 रुपए का पेट्रोल 2 दिन नहीं चलता था, <strong>वो आज</strong> 30 दिन चल गया.<br>दिन में 4 बार हाथ नहीं धोता था, <strong>वो आज</strong> 40 बार धो गया.</p><p>WFH के चक्कर मे बहोत जुठ बोले थे, <strong>वो आज</strong> WFH के चक्कर में फस गया.<br>Be Positive, Be Positive करता था, <strong>वो आज</strong> Positive शब्द से ही डर गया.</p><p>जिसने कभी एक ग्लास पानी उबला ना था, <strong>वो आज</strong> Dalgona बना गया.<br>जिसने कभी झाड़ू पकड़ा ना था, <strong>वो आज</strong> पूरा घर साफ कर गया.</p><p>पुलिसमैन पहले मेमो फाड़ता था, <strong>वो आज</strong> कुछ और ही फाड् गया.<br>गेम ऑफ़ थ्रोन, मनी हैस्ट देखता था, <strong>वो आज</strong> पूरा रामायण देख गया.</p><p>If you guys have found similar kinds of changes before lockdown and after lockdown then please let us know via comments.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a89e02d7fa39" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>