Find your people. Pick a challenge. Ship something real. The CreatorCon Hackathon is coming to the Community Pavilion for one epic night. Every skill level, every role welcome. Join us on May 5th and learn more here.

New button for Custom Table

vidhya_mouli
Tera Sage



I have a custom table (extended from kb_knowledge). I don't want to use the existing New button but created a new one. This is the script

var uri = action.getGlideURI();
        var path = uri.getFileFromPath() + '';
        path = path.substring(0, path.length - 5) + '.do';

        uri.set('sys_id', '-1');
        path = checkWizard(uri, path);
        if (path)
            action.setRedirectURL(uri.toString(path));

        action.setNoPop(true);

        function checkWizard(uri, path) {
            var already = uri.get('WIZARD:action');
            if (already == 'follow')
                return null;

            var wizID = new GlideappWizardIntercept(path).get();
            if (!wizID)
                return path;

            uri.set('sysparm_parent', wizID);
            uri.deleteParmameter('sysparm_referring_url');
            uri.deleteMatchingParameter('sysparm_list_');
            uri.deleteMatchingParameter('sysparm_record_');
            uri.deleteParmameter('sys_is_list');
            uri.deleteParmameter('sys_is_related_list');
            uri.deleteParmameter('sys_submitted');
            uri.deleteParmameter('sysparm_checked_items');
            uri.deleteParmameter('sysparm_ref_list_query');
            uri.deleteParmameter('sysparm_current_row');

            uri.set('sysparm_referring_url', uri.toString());
            uri.deleteMatchingParameter('fancy.');
            uri.deleteMatchingParameter('sys_rownum');
            uri.deleteMatchingParameter('sysparm_encoded');
            uri.deleteMatchingParameter('sysparm_query_encoded');
            uri.deleteParmameter('sysparm_refer');

            return 'wizard_view.do';
        }


I can see the button and when I click, I get this message: No records selected
When I select a record and click on the button, new record form opens. I don't understand the issue here.

 

I don't think there is an issue with the script. When I tried

 var url = 'x_bigas_mandator_0_mandatory_documents.do?sys_id=-1';
window.location.href = url;

had the same issue

 

 

Any suggestions please?

1 ACCEPTED SOLUTION

vidhya_mouli
Tera Sage

Found the issue. In the server side UI Action, action_name should start with sysverb.

View solution in original post

6 REPLIES 6

Dr Atul G- LNG
Tera Patron

Hi @vidhya_mouli 

The OOTB “New” button is global, so you need to hide it by checking where it is implemented.

*************************************************************************************************************
Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/dratulgrover [ Connect for 1-1 Session]

****************************************************************************************************************

vidhya_mouli
Tera Sage

I don't have an issue in showing the Global new button. Why is it asking me to select a record before creating a new record?

 

Ankur Bawiskar
Tera Patron

@vidhya_mouli 

why you created new? what's the use case?

Regards,
Ankur
Certified Technical Architect  ||  10x ServiceNow MVP  ||  ServiceNow Community Leader

Because this table extends KA, when I click on the New button, it takes me through Article template preview and it creates the article in kb_knowledge table. I don't want this. It should create the record in the custom table.