c.server.get not working in service portals
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
I have a requirement where user should get informational message if he is trying to attach a file of more than 3MB on a portal.
I'm trying to get this functionality done over a widget itself.
below are my client controller and server script.
Client controller:
Server script:
Now, I'm able to get size of attached of file on a server side in logs. but at the same I'm unable to fetch it on client side.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 weeks ago - last edited 2 weeks ago
can you please check with below line of code
instead of this try to do this and check what you receive from the server side to client side in response and put some log there
please try to use this
c.server.get(inputs).then(function(response) {
// Fetch the value returned by server
var fileSize = response.data.size;
if (fileSize > 3 * 1024 * 1024) { // >3MB
alert('File size exceeds 3MB. Please upload a smaller file.');
} else {
alert('File uploaded successfully. Size: ' + fileSize);
}
});
If my answer has helped with your question, please mark my answer as accepted solution and give a thumb up.
Thank You
