Dynamically passing a row number to Session.findbyid method - excel

I am trying to write a script which posts invoices in SAP through Excel (fairly new to this), and am running into the following error:
"The control could not be found by id".
The error is coming up at the below line:
session.FindById("wnd[0]/usr/subITEMS:SAPLFSKB:0100/tblSAPLFSKBTABLE/ctxtACGL_ITEM-HKONT[1,w_counter]").Text = w_glacc
Here, I am trying to pass the GL account number in the first row. There can be multiple rows, so I was hoping that instead of passing ctxtACGL_ITEM-HKONT[1,0]").Text, ctxtACGL_ITEM-HKONT[1,1]").Text etc. I wanted to initialize a counter and pass that value into this method.
Is there any way this can be achieved?

Found a solution:
Instead of passing just w_counter I had to pass "&w_counter&".
Previously, code was:
session.FindById("wnd[0]/usr/subITEMS:SAPLFSKB:0100/tblSAPLFSKBTABLE/ctxtACGL_ITEM-HKONT[1,w_counter]").Text = w_glacc
Now, it is:
session.FindById("wnd[0]/usr/subITEMS:SAPLFSKB:0100/tblSAPLFSKBTABLE/ctxtACGL_ITEM-HKONT[1,"& w_counter &"]").Text = w_glacc

Related

Matlab writematrix in Excel gives error: Name cannot be the same as built-in name

I want to copy an Excel file to a different path through Matlab and then write in it also using Matlab. Somehow I get the error: Name cannot be the same as built-in name.
As I want to write multiple times in the file, I don't want to solve this problem manuelly each time, I want the code to run through without me having to do something constantly.
Is there any way I can solve this problem all at once through code? Does this happen because I copy the Excel file first?
The code looks like this:
path_source_template1 = 'Blabla1\Template1.xlsx';
timestamp = datestr(now);
timestamp = strrep(timestamp, ':', '-');
timestamp = strrep(timestamp, ' ', '-');
path_output = fullfile('Blabla2\',timestamp);
mkdir(fullfile(path_output));
path_output_template1 = strcat(path_output,'\Template1.xlsx');
copyfile(path_source_template1,path_output_template1);
Then I want to write in the Template1.xlsx:
writematrix(test,path_output_template1,'Sheet','Test','Range','A1',UseExcel=true,AutoFitWidth=false);
Then I get this error:
enter image description here
The input to the writematrix file uses the name, value format, so in this line:
writematrix(test,path_output_template1,'Sheet','Test','Range','A1',UseExcel=true,AutoFitWidth=false);
you should have:
..., 'Sheet','Test','Range','A1','UseExcel', true,'AutoFitWidth', false);
Disclaimer: I haven't tested this, but I'm fairly certain this will fix your problem.
The correct call to the writematrix would be:
writematrix(test,path_output_template1, 'Sheet','Test','Range','A1', 'UseExcel', true,'AutoFitWidth',false);
When writing datetime data to a spreadsheet file, you must set both 'PreserveFormat' and the 'UseExcel' Name-Value pair to true to preserve the existing cell formatting. You can check the documentation writematrix.
In order to answer to the error I tested the code locally in Matlab 2019b and works well setting the test variable in this example way: test = magic(5);.
Maybe the error could be in the data that you use in test variable or in that if you run the code iteratively very fast the path_output could exist, One way to improve this could be with a more accurate timestamp.

No data output in Zapier when running a Python Code block and inputting a list

I am taking what I believe is a list from a previous step in Zapier and trying to then compare that list to a dictionary (within the code) to return a value or group of values as a new list. I have tested this out successfully on my desktop, but it does not result in the same output in Zapier.
My previous step takes a comma separated list and uses the Utlities formatter to return a list. My error could be that I am assuming this is a list.
I assume this is a list and use it as the input for the Run Python step.
When I test and review this, the outcome has no errors, but no data either. Any insight would be awesome as to how I make sure I understand the incoming data.
Zapier Test
list = []
for arg in input.values():
sharefile={
'Explore! Archaeology': 'https://hectv.sharefile.com/xxxx',
'Explore! Life as a Dog': 'https://hectv.sharefile.com/xxxx',
'Explore! Economics': 'https://hectv.sharefile.com/xxxx',
'The big chicken': 'https://hectv.sharefile.com/xxxx'
}
for index, (key, value) in enumerate(sharefile.items()):
if arg == key:
print(f'{arg} was matched')
list.append(value)
return(list)
With the help of the crew at Zapier, they explained that the input will always be text. Each input row is one dictionary entry.
Therefore, to access my first and only row of data, I had to use:
items = input_data['input']
This returns a string of data.
I hope that helps anyone with the issue.

How to save value of found document in mongoose as a variable?

Let's say I use findbyID{} to find a specific document in my collection, and this document has the value totalMedals to which I want to add the local variable medalsWonSinceLastUpdate. I would need a function along the lines of totalMedals = previousTotalMedals + medalsWonSinceLastUpdate, which would mean I need to capture the previous totalMedals in a variable. How would this be possible?
I have experimented with an ejs file that contains the value I want to access and then tried to access it through req.body.value, but this throws an error. I can run queries that find the documents, but I run into a brick wall when it comes to taking the variables to a wider scope.

2 Sequential Transactions, setting Detail Number (Revit API / Python)

Currently, I made a tool to rename view numbers (“Detail Number”) on a sheet based on their location on the sheet. Where this is breaking is the transactions. Im trying to do two transactions sequentially in Revit Python Shell. I also did this originally in dynamo, and that had a similar fail , so I know its something to do with transactions.
Transaction #1: Add a suffix (“-x”) to each detail number to ensure the new numbers won’t conflict (1 will be 1-x, 4 will be 4-x, etc)
Transaction #2: Change detail numbers with calculated new number based on viewport location (1-x will be 3, 4-x will be 2, etc)
Better visual explanation here: https://www.docdroid.net/EP1K9Di/161115-viewport-diagram-.pdf.html
Py File here: http://pastebin.com/7PyWA0gV
Attached is the python file, but essentially what im trying to do is:
# <---- Make unique numbers
t = Transaction(doc, 'Rename Detail Numbers')
t.Start()
for i, viewport in enumerate(viewports):
setParam(viewport, "Detail Number",getParam(viewport,"Detail Number")+"x")
t.Commit()
# <---- Do the thang
t2 = Transaction(doc, 'Rename Detail Numbers')
t2.Start()
for i, viewport in enumerate(viewports):
setParam(viewport, "Detail Number",detailViewNumberData[i])
t2.Commit()
Attached is py file
As I explained in my answer to your comment in the Revit API discussion forum, the behaviour you describe may well be caused by a need to regenerate between the transactions. The first modification does something, and the model needs to be regenerated before the modifications take full effect and are reflected in the parameter values that you query in the second transaction. You are accessing stale data. The Building Coder provides all the nitty gritty details and numerous examples on the need to regenerate.
Summary of this entire thread including both problems addressed:
http://thebuildingcoder.typepad.com/blog/2016/12/need-for-regen-and-parameter-display-name-confusion.html
So this issue actually had nothing to do with transactions or doc regeneration. I discovered (with some help :) ), that the problem lied in how I was setting/getting the parameter. "Detail Number", like a lot of parameters, has duplicate versions that share the same descriptive param Name in a viewport element.
Apparently the reason for this might be legacy issues, though im not sure. Thus, when I was trying to get/set detail number, it was somehow grabbing the incorrect read-only parameter occasionally, one that is called "VIEWER_DETAIL_NUMBER" as its builtIn Enumeration. The correct one is called "VIEWPORT_DETAIL_NUMBER". This was happening because I was trying to get the param just by passing the descriptive param name "Detail Number".Revising how i get/set parameters via builtIn enum resolved this issue. See images below.
Please see pdf for visual explanation: https://www.docdroid.net/WbAHBGj/161206-detail-number.pdf.html

Netsuite - Transfer Inventory error

I have been using NetSuite for only a short time, and already hate it. I am sorry if this is a stupid question, but I haven't been able to find an answer so far, either in the Netsuite docs, StackOverflow or other websites. In fact, the answers I found have resulted in an error.
My company requires a script to transfer inventory based on an EDI input file. Reading the file is no problem, even parsing it is working. However, actually inserting the data is proving problematic.
I have been able to insert normal records, but Inventory Transfer records are giving me problems.
From Stack Overflow I found and adapted some code into the following:
var xfer = nlapiCreateRecord("inventorytransfer");
xfer.setFieldValue("trandate", FormatDate("20160101"));
xfer.setFieldValue("location", 9);
xfer.setFieldValue("transferlocation", 9);
nlapiSelectNewLineItem('invt');
nlapiSetLineItemValue("invt","invtid",1, 189);
nlapiSetLineItemValue("invt","adjustqtyby", 1, "5");
nlapiCommitLineItem('invt');
var id = nlapiSubmitRecord(xfer);
The FormatDate function just exchanges the date from the text file into a system date NetSuite can understand.
However, when I run this code I get the following error:
USER_ERROR: You must enter at least one line item for this transaction.
I thought inserting the line item was the reason to use nlapiSelectNewLineItem, but I guess not. Also nlapiCreateNewLineItem doesn't seem to exist.
The values I am inserting are all just test data, as I'm testing this in the debugger. Location 9 exists, as does item 189.
My full script finds these id's based on string values from the text files. But since this is the section that doesn't work I have set it apart to test.
Can anyone help with this?
You did not specify the type of script you are using, but, looks like you are not setting the fields on the record object, but, setting the value on current record. Below, is the suggested code.
Also, there is no sublist named invt, it should be inventory. Also, there is no field as such invtid, I think most probably you want to setup item, the field Id should be item. You might want to refer SuiteScript Record Browser as well for a help on correct Ids
var xfer = nlapiCreateRecord("inventorytransfer");
xfer.setFieldValue("trandate", FormatDate("20160101"));
xfer.setFieldValue("location", 9);
xfer.setFieldValue("transferlocation", 9);
xfer.selectNewLineItem('inventory');
xfer.setCurrentLineItemValue("inventory", "item", 189);
xfer.setCurrentLineItemValue("inventory","adjustqtyby", "5");
xfer.commitLineItem('inventory');
var id = nlapiSubmitRecord(xfer);
If you are using Bin/Lot Numbered Items, please see help topic "Sample Scripts for Advanced Bin / Numbered Inventory Management"

Resources