How to move multiple rows to another sheet via API
I have code in C# that moves a row from one sheet to another, but I can only get it to work when I hard code the row id in the CopyOrMoveRowDirective line. What is the syntax for passing a row id into the statement? I have tried rowm.ID in place of 80233296095108, but i get a syntax error. Here is a simplified version of the code, but need to pass in the current rowid as I loop through.
foreach (Row rowm in sheet.Rows)
{
{
CopyOrMoveRowDestination destination = new CopyOrMoveRowDestination { SheetId = 336102784558980 };
CopyOrMoveRowDirective directive = new CopyOrMoveRowDirective { RowIds = new long[] { 80233296095108 }, To = destination };
CopyOrMoveRowResult results = smartsheet.SheetResources.RowResources.MoveRowsToAnotherSheet(3267158118557572, directive, null, null);
}
}
Thanks
Mike
Comments
-
Hi Michael,
If you haven’t already, I would recommend that you also check Stack Overflow.
https://stackoverflow.com/questions/tagged/smartsheet-api
Have a fantastic week!
Best,
Andrée Starå
Workflow Consultant @ Get Done Consulting
SMARTSHEET EXPERT CONSULTANT & PARTNER
Andrée Starå | Workflow Consultant / CEO @ WORK BOLD
W: www.workbold.com | E:andree@workbold.com | P: +46 (0) - 72 - 510 99 35
Feel free to contact me for help with Smartsheet, integrations, general workflow advice, or anything else.
-
Hi Mike,
It looks like you may have asked this question on StackOverflow here. That post goes over a solution the original poster found declaring a new variable to store the row id value and use that in the directive.
-
Thanks everyone. The key, as stated above, is that I needed to pass the .value in, which i originally was not doing.
-
Happy to help!
Best,
Andrée
SMARTSHEET EXPERT CONSULTANT & PARTNER
Andrée Starå | Workflow Consultant / CEO @ WORK BOLD
W: www.workbold.com | E:andree@workbold.com | P: +46 (0) - 72 - 510 99 35
Feel free to contact me for help with Smartsheet, integrations, general workflow advice, or anything else.
Categories
- All Categories
- 14 Welcome to the Community
- Customer Resources
- 64.8K Get Help
- 437 Global Discussions
- 138 Industry Talk
- 470 Announcements
- 4.9K Ideas & Feature Requests
- 129 Brandfolder
- 148 Just for fun
- 65 Community Job Board
- 486 Show & Tell
- 33 Member Spotlight
- 2 SmartStories
- 300 Events
- 36 Webinars
- 7.3K Forum Archives