Client Script - How do you obtain the current record ID when in detail view?

Client Script - How do you obtain the current record ID when in detail view?

I'm trying to gather the Account ID of the Account currently being looked at in Detail View of CRM.

I'm using a "button on click" client script execution, and am trying to create a logged call with input, based on button click.

eg - User goes to account, clicks button, screen pops with input, input then used in Call object creation and inserted to respective account.

Here is the sample script so far.

console.log("Canvas button clicked");
accountID = $Page.parent_record_id;
            var callRecord = {
                "data": [
                    {
                        "Subject": "Call Log",
                        "Call_Type": "Outbound",
                        "Call_Status": "Completed",
                        "Call_Start_Time": new Date().toISOString(),
                        "Description": notes,
                        "Account_Name": {
                            "id": accountId
                        }
                    }
                ]
            };

            console.log("Call record to be inserted: ", callRecord);

            ZDK.Apps.CRM.API.insertRecord({
                Entity: "Calls",
                APIData: callRecord
            }).then(function(data) {
                console.log("Call record created successfully: ", data);
                ZDK.Client.showMessage("Call logged successfully!");
            }).catch(function(error) {
                console.error("Error creating call record: ", error);
                ZDK.Client.showMessage("Failed to log call.");
            });

ZDK.Client.getInput(
    [{ type: 'text', label: 'Notes', name: 'notes' }],
    'Call Log',
    'Log Call',
    'Cancel',
    function(response) {
        console.log("User response: ", response);
        if (response) {
            var notes = response.notes;
            console.log("Notes: ", notes);

            var recordId = getRecordIdFromURL();
            if (recordId) {
                fetchAccountDetailsAndCreateCall(recordId, notes);
            } else {
                console.error("Record ID not found in URL.");
                ZDK.Client.showMessage("Failed to fetch record ID.");
            }
        } else {
            console.log("Call log canceled.");
            ZDK.Client.showMessage("Call log canceled.");
        }
    },
    function(error) {
        console.error("Error in notes pop-up: ", error);
    }
);



    Access your files securely from anywhere

        Zoho Developer Community




                                  Zoho Desk Resources

                                  • Desk Community Learning Series


                                  • Digest


                                  • Functions


                                  • Meetups


                                  • Kbase


                                  • Resources


                                  • Glossary


                                  • Desk Marketplace


                                  • MVP Corner


                                  • Word of the Day



                                      Zoho Marketing Automation


                                              Manage your brands on social media



                                                    Zoho TeamInbox Resources

                                                      Zoho DataPrep Resources



                                                        Zoho CRM Plus Resources

                                                          Zoho Books Resources


                                                            Zoho Subscriptions Resources

                                                              Zoho Projects Resources


                                                                Zoho Sprints Resources


                                                                  Qntrl Resources


                                                                    Zoho Creator Resources



                                                                        Zoho Campaigns Resources


                                                                          Zoho CRM Resources

                                                                          • CRM Community Learning Series

                                                                            CRM Community Learning Series


                                                                          • Kaizen

                                                                            Kaizen

                                                                          • Functions

                                                                            Functions

                                                                          • Meetups

                                                                            Meetups

                                                                          • Kbase

                                                                            Kbase

                                                                          • Resources

                                                                            Resources

                                                                          • Digest

                                                                            Digest

                                                                          • CRM Marketplace

                                                                            CRM Marketplace

                                                                          • MVP Corner

                                                                            MVP Corner





                                                                              Design. Discuss. Deliver.

                                                                              Create visually engaging stories with Zoho Show.

                                                                              Get Started Now