widget - action is not being pass to server side
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-01-2024 09:58 AM
hi everyone,
I am trying to create todo widget. widget with 2 buttons. approve and reject.
when I click the buttons, the variable "action" is not being pass to server side. so nothing happens.
Here is my code:
html:
<div class="widget-approval-widget">
<!-- Display Record Number and Description -->
<div>
<strong>Record Number:</strong> {{::data.record.number}} <br>
<strong>Description:</strong> {{::data.record.description}}
</div>
<!-- Command field (optional, if needed) -->
<div>
<textarea class="form-control" type="text" id="command" ng-model="data.command" placeholder="תכניס תגובה"></textarea>
</div>
<!-- Approve/Reject Buttons -->
<div>
<button ng-click="updateRecord('approve')" class="btn btn-primary button-width">Approve</button>
<button ng-click="updateRecord('reject')" class="btn btn-default button-width">Reject</button>
</div>
</div>
server script:
I could use some help, what's wrong with my code?
Thank you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-01-2024 06:11 PM
Hi @OpalH ,
The "action" is making it over to the server. The reason "if (action)" is not working after the client side sends the update is because it's nested in the "if(recordId)" condition. This works on inital load because server side by default runs first on load and the first line of the server script is setting recordId with the options.sysid.
Yes, I can see that there is an assignment for input.sysid however, that isn't going to work when the client side sends the update because there is no data.sysid being set on the client side.
You have to remember that when ".server.update()" is used it sends over the data object as the input object.
So currently your client side script has c.data.record and $scope.data.action which means your input object looks like this:
{
"action": "approve", //or reject depending on what was clicked
"record": { "description": "the description", "number": "the number", "sys_id": "the sys id" }
}
If the sys_id that you're looking for is the same that is for the "record" then changing the first line of the server script to something like the following should work:
//Change first line of server script
var recordId = input && input.record.sys_id ? input.record.sys_id : options.sysId;