Assign new user to document

i want to assign new user to issue document based on some condition , and i want this user to appear on form sidebar under assigned to.

frappe.ui.form.on(‘Issue’, {
refresh: function(frm) {
frappe.db.get_value(‘Issue’,,‘_assign’, function(value) {
if (value._assign.includes(‘user2’)){
let assignArray = JSON.parse(value[“_assign”]);
console.log(“assignArray” + assignArray);
let newAssignString = JSON.stringify(assignArray);
value[“_assign”] = newAssignString;
} else {
console.log(“Not OK”);
the result is [“user1”,“user2”,“user3”]
but user3 did not appear on
Screenshot 2023-06-13 000113

i need help please .

maybe just need to refresh the page?


Maybe you need more flexibility … but are you aware of this?

Hope this helps.

yes i am aware of this , my problem with assignment rule is that i can not assign two people on the same document …

if there is a solution for this problem i would not get into coding :slight_smile:


Assignment rule,as far I know, assign just 1 user …

Try this in your client script / .js code:

frm.assign_to.assign_to.dialog.fields_dict.assign_to.set_value( ["", ""])
frm.assign_to.assign_to.dialog.fields_dict.description.set_value("Your description ")

Hope this helps.

It works,sets the user in assigned_to field but does not add, so the dialog box is still open, and have to manually click on add. Also, it shows fields have missing values: Assign To.

Found Solution. Changed the code a bit.

setTimeout(function() {

Hi @Nirvisha_Soni @avc While assigning user How can I give write permission?

Hi @Robot,

When you click “Assign,” a dialog opens up, but there’s no option to set conditions or read/write options. so you can’t configure this using client scripts.

Thank You!


Thank you for the response,
If we can’t configure using client scripts, is there a chance to do it using server scripts?

It might be achievable through server scripting, but you have to explore the core functionality.

1 Like

Hello, can you elaborate the problem? what do you want to achieve?

Hi @Nirvisha_Soni, It was resolved.
Previously I didn’t give user role properly so for the assigned user, task became read only, Now I gave project user role so, everything works fine

BTW, I have one doubt. While creating task from server script using get_doc, Can I assign user? I’ve tried but it isn’t working tho

Yes, I have assigned the sales order. I used the To-Do feature for this task.

so = frappe.get_doc(
            "doctype": "ToDo",
            "allocated_to": user_id,
            "reference_type": "Sales Order",
            "reference_name": order id),
            "description": "Sales Order Assignment.",
            "status": "Open",
            "assigned_by": frappe.session.user,

I mean, I’m asking about this assigned_to