Normal Topic Limiting Mass Updates (Read 622 times)
BWETTLAUFER
Full Member
***
Offline



Posts: 216
Location: Cambridge, Ontario
Joined: Apr 9th, 2010
Limiting Mass Updates
Aug 22nd, 2016 at 4:24pm
Print Post Print Post  
Hi folks,

I've gotten to the point where I'm not wanting everyone to be running freeform Mass Updates, but we do have some pre-scripted updates I wouldn't mind letting folks use.

So ... I want to create a button that creates a pop up list of approved Mass Updates, and when they click on one, it executes on whatever is retrieved.

First step, how can I pull a list of mass updates as a string?

Thanks!
Blair
  
Back to top
IP Logged
 
Carl Underwood
Senior Member
Members
*****
Offline



Posts: 1351
Location: New Hampshire
Joined: Mar 11th, 2003
Re: Limiting Mass Updates
Reply #1 - Aug 23rd, 2016 at 4:20pm
Print Post Print Post  
See @SpecCommand() on page 394 of the Programming Guide.
  


Carl Underwood
CDU Computer Consulting LLC
Epsom, New Hampshire
Back to top
IP Logged
 
Carl Underwood
Senior Member
Members
*****
Offline



Posts: 1351
Location: New Hampshire
Joined: Mar 11th, 2003
Re: Limiting Mass Updates
Reply #2 - Aug 23rd, 2016 at 4:53pm
Print Post Print Post  
BTW, the manual omits one of the operation types, and it's the one you want:
SPEC_OPERATION_LIST, aka "6"

So you'd want to use something like one of the following, which both do the same thing:

@SpecCommand(SPEC_OPERATION_LIST, SPEC_TYPE_MASS_UPDATE, "")
or
@SpecCommand(6, 5, "")
  


Carl Underwood
CDU Computer Consulting LLC
Epsom, New Hampshire
Back to top
IP Logged
 
BWETTLAUFER
Full Member
***
Offline



Posts: 216
Location: Cambridge, Ontario
Joined: Apr 9th, 2010
Re: Limiting Mass Updates
Reply #3 - Aug 24th, 2016 at 4:16pm
Print Post Print Post  
For some reason, Sesame doesn't like the full descriptors only the integers -- is that because it is looking for me to include SBAS?

Here's what I wrote ... it pulls up the mass updates I have saved, but it fails to load and/or run my chosen spec ... what am I missing?

Code
Select All
var vSpec1 as string
var vSpec2 as string
var vSpec3 as string
var vSpec4 as string

vSpec1 = @SpecCommand(6,5,"")

vSpec2 = @containsstringarray(vSpec1,"",1)
vSpec2 = @sortstringarray(vSpec2,0)
vSpec3 = @Popupchoicelist(vSpec2,"CHOOSE AN UPDATE")

vSpec4 = @speccommand(1,5,vSpec3)
vSpec4 = @SpecCommand(3,5,vSpec3)

//Writeln(vSpec)

 

  
Back to top
IP Logged
 
Carl Underwood
Senior Member
Members
*****
Offline



Posts: 1351
Location: New Hampshire
Joined: Mar 11th, 2003
Re: Limiting Mass Updates
Reply #4 - Aug 25th, 2016 at 5:09am
Print Post Print Post  
Yes, you'd need to have the following line in Global Code, or at least at the top of the event where you want to use the text descriptors:
#include "sbasic_include.sbas"

I'm not sure what you're attempting to accomplish with @containsstringarray(vSpec1,"",1). This isn't really doing anything, is it?  Smiley

The main problem is that the three @SpecCommand lines are doing the following:
1. @SpecCommand(6,5,"") is getting a list of the specs.
2. @speccommand(1,5,vSpec3) is saving specs using the selected name. But since you have not loaded a spec (they are still blank), you are effectively clearing/deleting your current specs!
3. @SpecCommand(3,5,vSpec3) is simply viewing the currently loaded specs, of which, there isn't really any because there were never any loaded.

Try this instead:
Code
Select All
var vSpecList as String
var vSpec as String
var vResult as String

vSpecList = @SpecCommand(6, 5, "")				// Get a list of saved Mass Update specs
vSpecList = @SortStringArray(vSpecList, 0)			// Sort them

If vSpecList = ""						// Make sure there is at least one spec to show in popup list
	@MsgBox("No saved Mass Update specs found!", "", "(HINT: Save one first)")
Else
{
	vSpec = @PopupChoiceList(vSpecList, "CHOOSE AN UPDATE")	// Display the list of specs
	If vSpec <> ""						// Make sure a spec name was selected
	{
		vResult = @SpecCommand(0, 5, vSpec)		// LOAD the Mass Update spec
		vResult = @SpecCommand(2, 5, vSpec)		// RUN the Mass Update spec
	}
} 



You may want to add some code to check if you are actually in Update mode, and maybe a final popup asking the user to confirm before actually doing the Mass Update.
  


Carl Underwood
CDU Computer Consulting LLC
Epsom, New Hampshire
Back to top
IP Logged