02-02-2012 07:07 AM
I have client side code that is executed via the common tasks.
After the code is finished I would like to update a record in the database.
In the client side script, I already have the ID of the record to be updated.
Is there a possibility either to call a business rule or something or to do any kind of server request to update the record?
Would sData be the right thing to perform this task?
Solved! Go to Solution.
02-07-2012 04:54 AM - edited 02-07-2012 04:55 AM
I found a way to do this via the client side sData service:
// getting the service
var service = new Sage.SData.Client.SDataService(
{
serverName: window.location.host,
virtualDirectory: 'sdata',
applicationName: 'slx',
contractName: 'dynamic',
userName: 'admin',
password: 'mypassword',
json: true
}
);
// getting the (in this case it's attachment) record to be updated by the attachment ID I selected before (strID)
var request = new Sage.SData.Client.SDataSingleResourceRequest(service)
.setResourceKind('attachments')
.setResourceSelector("'"+strID+"'");
request.read(
{
success: function (entry)
{
// writing the new custom Id into a custom field in attachment
entry.CustomID = strNewCustomId;
// updating the selected record
request.update(entry);
}
});
03-08-2012 01:54 AM
Is there a way to retrieve the credentials from anywhere instead of hardcoding them into the JavaScript?
03-22-2012 02:51 AM
Hi,
you can use callback...
http://msdn.microsoft.com/en-us/library/ms178208.aspx
Hope this help.
05-09-2012 05:46 AM
I have solved this problem by using the credentials from the connection string and sending them to the JavaScript function as parameters.