Problem in Passing mulitple arguments

I got a strange problem while passing arguments from javascript file.

Here’s my js code
frappe.ui.form.on(‘Planning Form’, {
number_of_leaves: function(frm, cdt, cdn) {
var test = locals[cdt][cdn]
frappe.call({
method:“mcs_intech.mrs.doctype.planning_form.planning_form.test_seq”,
args:{
“phase_seq”: “Hello”
},
callback: function(r){
console.log(r)
}
})
}
});

And this is my python function code

@frappe.whitelist()
def test_seq(**args):
print(args, “Working”)

Although there is an argument called “phase_seq” my function returns empty dict like

{} Working

But when i pass argument name in the function like def test_seq(phase_seq):

It prints correctly. I don’t know where i’m doing wrong. Kindly help

Thanks in advance!!

@NCP Kindly help

Please check this:
https://www.sqlshack.com/understanding-args-and-kwargs-arguments-in-python/

Maybe, it’s helpful for you.

Thanks.

1 Like

Thanks @NCP

I understand about arguments but still the problem remains the same for me.

Tagging for some help

@johnskywalker @TurkerTunali @mingfang @brian_pond @rmehta

@ibalajib I’m not 100% sure about printing **args variable as it might be a string. You may have to run json.loads(args) to get a proper dictionary out of it.

Also, you should return something. The print function will just write to the standard output device on the server. So it will probably appear in your NGINX log, or another log.

My thoughts would be try return args.get("phase_seq", "Now Working")
If you get an error “Cannot access get on str object” then for sure you need
to parse args with json.loads.

1 Like