Community Tip - New to the community? Learn how to post a question and get help from PTC and industry experts! X
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.
Those two lines are equivalent to the code snippet that you provided in your previous message, just shorter.
Hi,
You can use substring:
var str = "This contains a string.";
var cut = str.substring(2,11); // cut = "is contai"
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
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);
}
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
Thank you! One more thing, the selectedOrderNum must be bound to the selectedRows of the same service right?
u mean replace the code starting from var params... till the end, right? If so, then it isnt working
Those two lines are equivalent to the code snippet that you provided in your previous message, just shorter.