Question:
How do I implement conditional logic for carrier codes based on the recipient's country in nShift? I want to apply specific services (e.g., SMS notifications) based on the destination country.
Answer:
You can use the SWITCH function within an expression field in the Import Setup to dynamically assign carrier codes based on the recipient's country. This allows you to trigger specific services tied to those carrier codes.
Step-by-Step Instructions:
Create a New Carrier Code with the Desired Service:
- Locate the Import Setup select the Carrier Presettings tab.
- Click "New".
- Enter a new carrier code (e.g., "Packages-SMS").
- Select the appropriate product.
- Activate the desired service (e.g., "Notification SMS").
- Click "OK".
Configure the Import Setup:
- In the "Import Setup" tab, locate your "Carrier Code" field (e.g., F1).
- Map this field to "Unknown->Unknown".
- Click "Fields" to add a new field.
- In the dialog, select "Expression."
- Set the Field Segment: to CarrierCode->Shipment.
Define the Expression:
In the "Imported Value" field for the new expression field, enter your SWITCH expression. Example:
SWITCH(<Carrier Code Field>-<Country Code Field>,Packages-DK|Packages-SMS|Packages-SE|Packages-SMS")
- Replace and with the actual field identifiers from your import file (e.g., F1 and F7).
- Each pipe-separated argument within the SWITCH function represents a condition and its corresponding result.
- Before the pipe symbol (|) is the combined value to check (Carrier Code-Country Code).
- After the pipe symbol (|) is the new carrier code to apply if the condition matches.
Set a Default Value:
In the "Default Value" field of the expression field, enter the original carrier code field (e.g., F1). This handles cases where no country-specific match is found in the SWITCH expression.
Test and Save:
- Click "Preview Expressions" to verify the logic.
- Click "OK" to save the import setup.
Import the File:
Import your file to test the new logic. Shipments to countries included in the SWITCH statement will have the new carrier code and its associated services applied. Shipments to other countries will use the default carrier code.
Short Explanation:
The Import Setup allows conditional logic through expressions. The SWITCH function checks combinations of carrier code and country code from your import file. If a match is found, it applies a new carrier code (and its associated services). A default value ensures that shipments to unmatched countries still get processed with their original carrier code.