Get Nested Form Entry Value or Count Repeater (Beta) number of rows and calculate [RESOLVED]

Hello, Samuel thanks for stopping by to respond my thread i really appreciate it man!, By the way are you a Ghanaian you have our accent (in this video) :slightly_smiling_face: .

I managed to get the value via CGPT later on code below, But the problem i’m facing now is assuming you add one or just 2 items to the nested form, The xml sent to our parent web service about 19 more previous items that’s been submitted via the nested form will be included in the xml, Why?

add_action('gform_after_submission_65', 'test_to_third_party', 10, 3);
function test_to_third_party($entry, $form, $entry_id)
{
    if (rgpost('gform_submit') != $entry['form_id']) {
        return;
    }

    $url      = 'IP Address';
    $encoding = 'UTF-8';
    $username    = htmlspecialchars("Organization Name", ENT_XML1, $encoding);
    $password  = htmlspecialchars("cc@2441123", ENT_XML1, $encoding);
    $org_num  = htmlspecialchars("77889900", ENT_XML1, $encoding);
    $org_pin    = htmlspecialchars($entry['6'], ENT_XML1, $encoding);

    // Get the nested form entries
    $nested_form_entries = GFAPI::get_entries([
        'form_id' => 66,
        'entry_meta' => [
            'parent_entry_id' => $entry_id
        ]
    ]);

    foreach ($nested_form_entries as $nested_entry) {
        $item_list = '';
        $item_entry_id = rgar($nested_entry, 'id');

        // Get the items from the nested entry
        if ($item_entry_id) {
            $item_entry = GFAPI::get_entry($item_entry_id);
            if ($item_entry) {
                $item_list = rgar($item_entry, '9');
                $donaterkey = $nested_entry['10'];
            }
        }

        $products = htmlspecialchars($item_list, ENT_XML1, $encoding);

        $xml = "<?xml version=\"1.0\" encoding=\"$encoding\"?>
		<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:tem=\"http://tempuri.org/\">		
			<soapenv:Header/>
			<soapenv:Body>
				<tem:CharityBuild>
					<tem:username>$username</tem:username>
					<tem:password>$password</tem:password>
					<tem:org_num>$org_num</tem:org_num>
					<tem:products>$products</tem:recipientMsisdn>
					<tem:salt_key>$donaterkey</tem:salt_key>
					<tem:org_pin>$org_pin</tem:org_pin>
				</tem:CharityBuild>
			</soapenv:Body>
		</soapenv:Envelope>";
		
        // Log the XML request
        $xml_log = "XML Request: \n" . $xml . "\n\n";
        error_log($xml_log, 3, $_SERVER['DOCUMENT_ROOT'] . '/temp_review.txt');

		// Set up the cURL request
		$ch = curl_init($url);
		if ($ch === false) {
			throw new RuntimeException("cURL initialization failed: " . curl_error());
		}

		$result = curl_setopt_array($ch, [
			CURLOPT_POST => 1,
			CURLOPT_HTTPHEADER => ['Content-Type: text/xml'],
			CURLOPT_CUSTOMREQUEST => 'POST',
			CURLOPT_POSTFIELDS => $xml,
			CURLOPT_RETURNTRANSFER => 1,
			CURLOPT_URL => $url,
			CURLOPT_RETURNTRANSFER => 1,
			CURLOPT_SSL_VERIFYHOST => 0,
			CURLOPT_SSL_VERIFYPEER => 0,
		]);

		if ($result === false) {
			throw new RuntimeException("cURL options failed: " . curl_error($ch));
		}

		// Execute the cURL request
		$output = curl_exec($ch);

		if ($output === false) {
			throw new RuntimeException("cURL request failed: " . curl_error($ch));
		}

		// Close the cURL request
		curl_close($ch);
	
	}

}