creditcardsps
creditcardsps2w ago

Buildship Database - Create Document within Loop Node not working correctly

Hello - thanks in advance for any help. Beginner here. I have a workflow where in one of the first nodes I'm pulling some data that a user selected about which credit card(s) they use. The output of this (called "selectedCards") is below: { "id": "OkmQ6tjC33NQj4Ahexwz2sX8z4l1", "fieldKey": "selectedCards", "value": [ "discover-it", "capital-one-venture", "chase-sapphire-preferred" ], "status": "success!" } Later in a loop node, I'm trying to input 3 rows in the buildship database (1 for each of the "values" above) and input that value in the "card_id" field. So I basically want 3 rows, 1 with "discover-it" in the "card_id" field, 1 with "capital-one-venture" in the "card_id" field, and 1 with "chase_sapphire-preferred" in the "card_id" field. In the loop node, I've input "selectedCards.value" as the item. Within the loop, I'm trying to create a new document in the "user_card_recs" collection and input the card_id which is basically the string of the current item in the loop. When I use a log, it shows the below: [ 0:"discover-it" 1:"capital-one-venture" 2:"chase-sapphire-preferred" ] But in the collection, 1 row is added, and the card_id shows as "discover-it,capital-one-venture,chase-sapphire-preferred". Can anyone help me figure out why this is happening?
2 Replies
AI Support
AI Support2w ago
AI Support Bot Information
<@1361095014922322161> you can react on the relevant answer (message) with a ✅ in this thread when you think it has been solved, by the bot or by a human! Anyone can react on this message with a ❌ if the GPT bot is unhelpful or hallucinating answers. Please note: Team members will review and answer the questions on best efforts basis.
AI Support
AI Support2w ago
AI Response
It seems like you're encountering an issue where all card IDs are being concatenated into a single field instead of creating separate rows for each card ID. This issue usually happens when the loop node is not properly set up to iterate over individual items as expected. Here's a step-by-step process to address this: 1. Check Loop Node Configuration: - Ensure that the loop node is properly configured to iterate over the array. The item configuration should strictly point to the array you want to iterate over. In your case, selectedCards.value should be set correctly as the collection or list to iterate over. 2. Item Usage within the Loop: - Within the loop, make sure you are using the correct reference for the current item. Typically, you should be using something like currentItem or similar, depending on how your platform represents the current looped item. This ensures that for every iteration, only the respective card ID is picked. 3. Database Inserter Configuration: - In the node where you are inserting data into the "user_card_recs" collection, ensure you're using the correct reference for the card ID value. - If your platform supports referencing the loop’s current item, use that to populate the card_id field. 4. Debugging and Logging: - Use logging inside the loop to check what value is being processed in each iteration. This can help ensure that the correct item is being fetched. - You should see one log entry per loop iteration, matching the card IDs. 5. Platform-Specific Guidance: - Double-check the platform documentation or consult with support if there’s a specific syntax or setup for loops and database operations. By following the above steps, you should be able to create three separate database entries, each with its own card ID from the selectedCards.value array. If these adjustments do not resolve the issue, it may be useful to provide more specifics about how the loop or data-mapping nodes are configured so that more tailored advice can be offered.
BuildShip AI Support

Did you find this page helpful?