UI Builder Add comments to Approval record

Goutham9
Tera Contributor

Hi Everyone,

As part of a requirement, we had to add the input entered in a Textarea component as a comment on Approval table (sysapproval_approver) when they click on a Button. I'm able to get the text entered in the textarea and On click of the button, I'm trying to add it as comment via "Update Record", I am not able to find "Comments" in the list of fields and I also tried using the script. Even though I'm getting all the values, For some reason it's neither saving the state nor adding comment

 

function handler({api,event, helpers, imports}) {
  let fields ="state=" + event.payload.status+"^comments="+api.state.reason;
  api.data.update_record_1.execute({
    table: "sysapproval_approver",
    recordId : api.context.props.sysId,
    templateFields: fields, //state=rejected^comments=test
    useSetDisplayValue: false
  });
}

 

Appreciate the help in advance

@Brad Tilton 

2 REPLIES 2

Brad Tilton
ServiceNow Employee
ServiceNow Employee

I don't see anything wrong with this, but the fact that there are no fields available when you try to set this through the UI probably isn't a great sign. If you hardcode the field property with the string you've commented out does it work?

MrGupta__
Tera Expert

Hi @Goutham9 ,
Did you find any solution for that?
Actually, I am also trying to add comments to a case when user click the button component.
If you got any solution then please reply.

Regards,
MrGupta__