How to redirect from a custom page to form


I have created a custom page and have a button for creating job card. But its not redirecting to a form, i am not sure how to redirect to a form, kindly help.

frappe.pages[‘test’].on_page_load = function(wrapper) {
var page = frappe.ui.make_app_page({
parent: wrapper,
title: ‘Job Card’,
single_column: true
page.set_primary_action(“Create Job Card”, function(){
var d = new frappe.ui.Dialog({
title: (‘Create Job Card’),
‘fields’: [
{‘fieldname’: ‘work_order’, ‘fieldtype’: ‘Link’, ‘options’: ‘Work Order’,‘label’:
(‘Work Order Id’)}
primary_action_label: __(‘Create’),
primary_action: function(d) {
method: “sample.sample.job_card.create_job_card”,
args: {
work_order_id : d.work_order
freeze: true,
callback: function(r){
if(!r.exc) {
var doc = frappe.model.sync(r.message);
frappe.set_route(“Form”, r.message.doctype,;

Thanks in advance!

hi Jenisha,

try this

             frm.add_custom_button(__('Button Name'),function() { 
		frappe.route_options = {
				"customer": frm.doc.field_name
		frappe.set_route("Form", "Target Doctype Name");

Hi, what exactly you want to do? can you explain in more detail.

This worked , thanks you!