How to retrieve parent ID on load

Discussions related to customizing hooks. Hooks are documented at http://bigprof.com/appgini/help/advanced-topics/hooks/
Post Reply
User avatar
zibrahim
Veteran Member
Posts: 137
Joined: 2020-01-28 18:30
Location: Malaysia

How to retrieve parent ID on load

Post by zibrahim » 2020-07-10 02:23

Hi there,
Appreciate if someone can teach me how to retrieve the ID of parent table which automatically generated when we click add item at child table.
Example, when I click the add item here...
Screen Shot 2020-07-10 at 10.16.46 AM.jpg
Screen Shot 2020-07-10 at 10.16.46 AM.jpg (78.57 KiB) Viewed 5273 times
I will get this modal window with the parent ID already assigned as 10778
Screen Shot 2020-07-10 at 10.14.47 AM.jpg
Screen Shot 2020-07-10 at 10.14.47 AM.jpg (79.23 KiB) Viewed 5273 times
What I want to do is actually retrieve the value of one of the field from the parent table based on the ID.
I have the following js to retrieve it on change but what I want is to retrieve it on load.

Code: Select all

$j('#Service_ID-container').on('change', function () {
    var pid = $j('#Service_ID-container').select2('val');
    if (pid == '{empty_value}') {
        $j('#Amount').val('');
    } else {
        $j.ajax({
            url: 'hooks/ajax-service_item_balance.php',
            data: {
                pid: pid
            },
            success: function (data) {
                $j('#Amount').val(data);
            }
        });
    }
});
Appreciate your help and support.
Thanks.

Zala
Zala.
Appgini 24.10.1579, MacOS 14.3.1 Windows 11 on Parallels.

pbottcher
AppGini Super Hero
AppGini Super Hero
Posts: 1635
Joined: 2018-04-01 10:12

Re: How to retrieve parent ID on load

Post by pbottcher » 2020-07-10 05:53

Hi,

not sure I really get your use case, but on load you should just retrieve the value of the field

$j('#Service_ID').val()
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.

User avatar
zibrahim
Veteran Member
Posts: 137
Joined: 2020-01-28 18:30
Location: Malaysia

Re: How to retrieve parent ID on load

Post by zibrahim » 2020-07-10 06:40

Thanks Pböttcher !!! You are fantastic and kind to noob like me.
Zala.
Appgini 24.10.1579, MacOS 14.3.1 Windows 11 on Parallels.

Post Reply