Hi All,
I'm struggling with what I thought would be a simple value substitution.
I have this C# String referencing a Javascript SData call and I want to substitute the current Entity ID (OpportunityID) into the ResourceSelector parameter.
The problem is adding single (or double) quotes around the OpportunityID in the script referenced below:
string currentEntityId = opportunity.Id.ToString();
string jscript = @function getProductVersion() {
var currentEntityId = Sage.Utility.getCurrentEntityId(); //oppId
var gridid = '" + gridID + @';;
//Get dijit grid
var grid = dijit.byId(gridid);
//fetch rows
grid.store.fetch({
onComplete: function (items) {
dojo.forEach(items, function (item, index) {
var oppProdId = item.$key;
//Build request URI
var service = Sage.Data.SDataServiceRegistry.getSDataService('system'),
request = new Sage.SData.Client.SDataSingleResourceRequest(Sage.Data.SDataServiceRegistry.getService(service))
.setResourceKind('Opportunities')
.setResourceSelector('+Sage.Utility.getCurrentEntityId()+')
request.uri.pathSegments[1].text = 'dynamic';
request.read({
success: function(entry) { console.log(entry); }
});
}) //end dojo.forEach
} // end onComplete
//End fetch
});
My console output Results in:
localhost:3333/.../Opportunities(%2BSage.Utility.getCurrentEntityId()%2B)?_includeContent=false&format=json&_t=1490816135760
More attempts result in:
Doesn't parse properly:
setResourceSelector('+Sage.Utility.getCurrentEntityId()+')
Setting the string in C# and passing it in:
string currentEntityId = opportunity.Id.ToString();
.setResourceSelector('"+ currentEntityId +@'
Results in:
localhost:3333/.../Opportunities(O6UJ900D5726)?_includeContent=false&format=json&_t=1490634729109
Which also doesn't parse becasue the opportunityID is missing quotes. This above example is the closest I've gotten.