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

Its_Azar
Mega Sage

Hi there @vidhya_mouli 

 

Your UI Action is a List button, and list actions require at least one selected record, otherwise it shows “No records selected”.

That’s why it works only after selecting a record. It’s not a script issue.

Use a Form button (or remove the List option) for creating new records. “New” actions should not be list-dependent.

☑️ If this helped, please mark it as Helpful or Accept Solution so others can find the answer too.

Kind Regards,
Azar
Serivenow Rising Star
Developer @ KPMG.

vidhya_mouli
Tera Sage

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