Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Meghana Lokrey 5 posts 95 karma points
    Sep 27, 2024 @ 12:51
    Meghana Lokrey
    0

    Fetch a node based on a form text filed value before form submit Umbraco 8

    Form has a accountNumber field, when entered, looks for a node with same Account Number under Account Number Details node in content section and grabs the address and email under it r. Below is my code. Account number hardcoded, it works. Doesnt work as Account Number entered in textbox is not being recognized. I tried using HttpContext.Current.Request["acountNum-req"] but no luck. Need help. @{ string deliveryList = ""; string addressList = ""; string accNum = "1000909";

    ((((((I need to get accNum from a text input field instead of hardcoded value))))))

                var accountDetailsNode = Model.AncestorOrSelf("Root").Children
                                            .Where(x => x.Name == "Account Numbers Details")
                                            .FirstOrDefault();
    
                if (accountDetailsNode != null)
                {
                    var accountNumberNodes = accountDetailsNode.Children("accountNumber");
                    if (accountNumberNodes.Any())
                    {
                        foreach (var accountNumberNode in accountNumberNodes)
                        {
                            var accountNumber = accountNumberNode.Name;
    
                            if (accountNumber == accNum)
                            {
    

    var jubiliantAddresses = accountNumberNode.Children("jubiliantDeliveryAddress"); foreach (var jubiliant in jubiliantAddresses) { // Handle jubiliantEmail which might be a collection var emails = jubiliant.Value<>

                                    // Concatenate emails into a single string
                                    string emailString = string.Join("; ", emails);
                                    deliveryList += ",\"" + jubiliant.Value<string>("jubiliantAddress") + "\"";
                                    addressList += ",\"" + jubiliant.Value<string>("jubiliantAddress") + "/ " + emailString + "\"";
    
                                }
                                var regAddresses = accountNumberNode.Children("nonJubiliantAddress");
                                foreach (var regAddress in regAddresses)
                                {
                                    deliveryList += ",\"" + regAddress.Value<string>("address") + "\"";
                                    addressList += ",\"" + regAddress.Value<string>("address") + "\"";
                                }
                                deliveryList = deliveryList.Substring(1);
                                addressList = addressList.Substring(1);
                            }
                        }
                    }
    
                }
    

    }

Please Sign in or register to post replies

Write your reply to:

Draft