Copy Master Detail to another table

This public forum is for user-to-user discussions of PHPMaker. Note that this is not support forum.
ameisfine
User
Posts: 74

Re: Copy Master Detail to another table

Post by ameisfine »

mobhar wrote:
Always post your latest code for more discussion.
Hi mobhar,

$("input[name='x_Is_Proforma']").change(function() {
if (this.value == "Y") {
$("#x_Sales_Number").val("PROFORMA");
} else if (this.value == "N"){
$salesnum = GetNextSalesNumber();
$(this).fields("Sales_Number").value($salesnum);
}
});

Result(Inspector/Console ) : ReferenceError: GetNextSalesNumber is not defined
I don't know how to define / call that function in here


mobhar
User
Posts: 11703

Post by mobhar »

If this is the PHP code:
$salesnum = GetNextSalesNumber();

then you need to define that GetNextSalesNumber() function in "Global Code" under "Server Events" -> "Global" -> "All Pages".

In addition, since that is the PHP code, then you have to enclose it with <?php ... ?> tags, so that code above should be like this:

<?php $salesnum = GetNextSalesNumber(); ?>

Also, this code:
$(this).fields("Sales_Number").value($salesnum);

should be:
$(this).fields("Sales_Number").value("<?php echo $salesnum; ?>");


ameisfine
User
Posts: 74

Post by ameisfine »

Function GetNextSalesNumber is already in Global.
And yes with this small changes it works now.
Thank you 100000x mobhar.


Post Reply