Splitting or matching a string in a service
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Splitting or matching a string in a service
Hi,
I want to take a part of input string and compare it with an existing string and store it. There are functions like split, splice , includes, etc in JS but I am unable to use them. How can I achieve the functionality?
Solved! Go to Solution.
- Labels:
-
Troubleshooting
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Those two lines are equivalent to the code snippet that you provided in your previous message, just shorter.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Hi,
You can use substring:
var str = "This contains a string.";
var cut = str.substring(2,11); // cut = "is contai"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Just checked it, can you tell me why it isn't working in the infotable for loop? outside the loop it works fine! The thing is, I am comparing the string with another string which is in the infotable
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
hi, I was able to solve my problem without using the functions as I am using mssql db. I have another problem now. I am fetching some strings from db and displaying it in a list dropdown. I select one and submit. When i submit, the selected item must be deleted from the list and updated list must be shown. Can u help me in this? This is my code:
var res = Things["mes_db"].GetOrderNum({
prodPartNum: prodPartNum /* STRING */
});
var params = {
infoTableName : "InfoTable",
dataShapeName : "OrderNumber"
};
var result = Resources["InfoTableFunctions"].CreateInfoTableFromDataShape(params);
result=res;
var tableLength = result.rows.length;
for (var x=0; x < tableLength; x++) {
var row = result.rows[x];
if(row.order_num.trim()==selectedOrderNum.trim())
result.RemoveRow(x);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
A typical approach is to delete the selected row in the database and re-run the query after that.
If you only need to delete a row in an infotable, then you can replace your code with those two lines (make sure all your strings are timmed before doing it):
var result = Things["mes_db"].GetOrderNum({ prodPartNum: prodPartNum });
result.Delete({ order_num: selectedOrderNum });
/ Constantine
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Thank you! One more thing, the selectedOrderNum must be bound to the selectedRows of the same service right?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
u mean replace the code starting from var params... till the end, right? If so, then it isnt working
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Those two lines are equivalent to the code snippet that you provided in your previous message, just shorter.
