BOBJ SDK Add Group MemberOf Parent Group - business-objects

All,
I add a group to be a child of the parent group but, it is not becoming a member of the parent group. I have to go in and set it manually.
Anyone know how this works?

I had to play with it and do a little research on the BOB Forum but I figured it out, though its non-intuitive.
I'm going to assume you know how to get the parent group IUserGroup object.
// get the plugin manager
IPluginMgr pluginMgr = store.getPluginMgr();
// Retrieve the User plugin.
IPluginInfo groupPlugin = pluginMgr.getPluginInfo("CrystalEnterprise.UserGroup");
// Create a new InfoObjects collection.
IInfoObjects newInfoObjects = store.newInfoObjectCollection();
// Add the User plugin to the collection.
newInfoObjects.add (groupPlugin);
// Retrieve the newly created user object.
IUserGroup newUserGroup = (IUserGroup)newInfoObjects.get(0);
// build the new group
String newGroupName = "My Test Group";
newUserGroup.setTitle(newGroupName);
newUserGroup.setDescription("Just for sample test code");
store.commit(newInfoObjects);
// now that things commited associate the parent group
if(parentGroup != null)
{
parentGroup.getSubGroups().add(new Integer(newUserGroup.getID()));
store.commit(parGroupObjs);
}
The big stumper is that you you would expect to just use the setParentID() method. Word of warning this this was only tested under BO XI R2, not R3, so it may not be 100% correct for the current version.

Related

Script properties becomes corrupt: Failed to save Project Properties for script

Script properties becomes "corrupt" after a call to "PropertiesService.getScriptProperties().setProperties(properties)" in my script. By "corrupt", I mean I can no longer add or edit existing properties in: "File -> Project properties -> Script properties", and when I first try I receive the error message "Failed to save Project Properties for script." I've tried deleting all properties and re-adding them, I tried deleting all browser cache, and I tried minimizing my Properties calls to ensure(?) I'm not exceeding quotas.
After this error, going to "File -> Project properties" results in in a endlessly spinning busy cursor while it tries to load the "Info" tab. Re-loading the spreadsheet allows "File -> Project properties" to properly load, but any edits made to properties in the "Script properties" tab brings back the error and spinning cursor problem.
I've narrowed down the culprit in my script but I cannot figure out why it's causing this problem. In my "onOpen()" method I am building up ~125 properties, and then I set them with one call to "setProperties()". The properties go into Script Properties okay, and they function as expected, but this programmatic setting of script properties is definitely the cause of the "Failed to save Project Properties for script." error message.
Link to a copy of my Google spreadsheet containing the script causing the problem. The 3 calls causing the problem are commented with "SETPROPS", and the call to set the properties is commented with "BROKE!". This problem, or ones similar, have come up in the past but seem to be "fixed" or no longer occur.
The code sequence is as follows:
I clear all script properties with: PropertiesService.getScriptProperties().deleteAllProperties()
I call three methods, each taking a "properties" argument.
Each of these 3 methods does nearly the same thing. They each add key/value pairs to "properties".
After each of the 3 methods is called, I set the properties with:
if (Object.getOwnPropertyNames(properties).length !== 0)
{
PropertiesService.getScriptProperties().setProperties(properties);
}
Here is one of the 3 methods that adds to the "properties" var (initialize with: var properties = {};). The other 3 methods add to the properties variable in the same manner, but operate on different data.
function setScriptPropertiesShipSizesForFaction(properties, factionName)
{
var dataSheetName = factionName + "Data";
var dataSheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(dataSheetName);
var shipValues = dataSheet.getRange('B3:D200').getValues();
var index = 0;
while ( (index < shipValues.length) && (shipValues[index][0] != "") )
{
var key = '_shipSize_' + normalize(shipValues[index][0]);
var value = shipValues[index][2];
properties[key] = value;
index++;
}
}
I believe I am not exceeded any Google script quota. I do not get any error messages from the call to "setProperties", and I do not see any errors in Google's Stackdriving Logging. At the bottom of this post I have a list of what I am setting in ScriptProperties. It's logging output, with syntax: key=value.
_shipSize_ArquitensCC=S
_shipSize_ArquitensLC=S
_shipSize_AssaultFrigateMk2A=M
_shipSize_AssaultFrigateMk2B=M
_shipSize_CR90-A=S
_shipSize_CR90-B=S
_shipSize_GR-75CombatRetrofits=S
_shipSize_GR-75MediumTransports=S
_shipSize_Gladiator1=S
_shipSize_Gladiator2=S
_shipSize_GozantiAssault=S
_shipSize_GozantiCruisers=S
_shipSize_HammerheadScout=S
_shipSize_HammerheadTorpedo=S
_shipSize_ISD1=L
_shipSize_ISD2=L
_shipSize_ISDCymoon=L
_shipSize_ISDKuat=L
_shipSize_InterdictorCombat=M
_shipSize_InterdictorSuppression=M
_shipSize_MC30cScout=S
_shipSize_MC30cTorpedo=S
_shipSize_MC75ArmoredCruiser=L
_shipSize_MC75OrdnanceCruiser=L
_shipSize_MC80AssaultCruiser=L
_shipSize_MC80BattleCruiser=L
_shipSize_MC80CommandCruiser=L
_shipSize_MC80StarCruiser=L
_shipSize_Nebulon-BEscort=S
_shipSize_Nebulon-BSupport=S
_shipSize_PeltaAssault=S
_shipSize_PeltaCommand=S
_shipSize_QuasarFire1=M
_shipSize_QuasarFire2=M
_shipSize_Raider1=S
_shipSize_Raider2=S
_shipSize_Victory1=M
_shipSize_Victory2=M
_upgradeKeyPrefix_EmpireDEFENSIVE 2=6.0
_upgradeKeyPrefix_EmpireDEFENSIVE=5.0
_upgradeKeyPrefix_EmpireEXPERIMENTAL 2=8.0
_upgradeKeyPrefix_EmpireEXPERIMENTAL=7.0
_upgradeKeyPrefix_EmpireFLEET COMMAND=9.0
_upgradeKeyPrefix_EmpireFLEET SUPPORT=10.0
_upgradeKeyPrefix_EmpireION CANNONS=11.0
_upgradeKeyPrefix_EmpireOFFENSIVE 2=13.0
_upgradeKeyPrefix_EmpireOFFENSIVE=12.0
_upgradeKeyPrefix_EmpireOFFICER=4.0
_upgradeKeyPrefix_EmpireORDNANCE=14.0
_upgradeKeyPrefix_EmpireSUPPORT TEAM=15.0
_upgradeKeyPrefix_EmpireTITLE=3.0
_upgradeKeyPrefix_EmpireTURBOLASER 2=17.0
_upgradeKeyPrefix_EmpireTURBOLASER=16.0
_upgradeKeyPrefix_EmpireWEAPONS TEAM 2=19.0
_upgradeKeyPrefix_EmpireWEAPONS TEAM=18.0
_upgradeKeyPrefix_RebelDEFENSIVE 2=7.0
_upgradeKeyPrefix_RebelDEFENSIVE=6.0
_upgradeKeyPrefix_RebelFLEET COMMAND=8.0
_upgradeKeyPrefix_RebelFLEET SUPPORT=9.0
_upgradeKeyPrefix_RebelION CANNONS=10.0
_upgradeKeyPrefix_RebelOFFENSIVE=11.0
_upgradeKeyPrefix_RebelOFFICER 2=5.0
_upgradeKeyPrefix_RebelOFFICER=4.0
_upgradeKeyPrefix_RebelORDNANCE 2=13.0
_upgradeKeyPrefix_RebelORDNANCE=12.0
_upgradeKeyPrefix_RebelSUPPORT TEAM=14.0
_upgradeKeyPrefix_RebelTITLE=3.0
_upgradeKeyPrefix_RebelTURBOLASER 2=16.0
_upgradeKeyPrefix_RebelTURBOLASER=15.0
_upgradeKeyPrefix_RebelWEAPONS TEAM=17.0
_upgradeSize_BailOrgana=ML
_upgradeSize_DisposableCapacitors=SM
_upgradeSize_GovernorPryce=ML
_upgradeSize_HardenedBulkheads=L
_upgradeSize_StrategicAdviser=L calculatedDataSheetName=Calculated Data cellCommander=E2 colEmpirePlayerNames=1 colRebelPlayerNames=8
colShipNames=2 colSquadNames=2 colUpgradesStart=3
colVariableUpgradesEndEmpire=19 colVariableUpgradesEndRebel=17
colVariableUpgradesStartEmpire=5 colVariableUpgradesStartRebel=6
disabledBgColor=#999999 enabledBgColor=#93c47d
factionNameEmpire=Empire factionNameRebel=Rebel
indexFleetSheetsStart=3
multipleIconUpgrade_BoardingEngineers=OFFENSIVE,WEAPONS TEAM
multipleIconUpgrade_BoardingTroopers=OFFENSIVE,WEAPONS TEAM
multipleIconUpgrade_ChamSyndulla=OFFENSIVE,WEAPONS TEAM
multipleIconUpgrade_DarthVader=OFFENSIVE,WEAPONS TEAM
multipleIconUpgrade_JynErso=OFFENSIVE,WEAPONS TEAM playersPerTeam=3
rowPlayerNamesStart=7 rowShipsEnd=17 rowShipsStart=6
rowSquadNamesEnd=44 rowSquadNamesStart=21 rowUpgradeNames=5
sheetNameSystemTracking=Systems Tracking sheetNameTeamStatus=Team
Status upgradeKeyPrefix=_upgradeKeyPrefix_
upgradeKeyPrefixEmpireDEFENSIVE 2=6.0
upgradeKeyPrefixEmpireDEFENSIVE=5.0
upgradeKeyPrefixEmpireEXPERIMENTAL 2=8.0
upgradeKeyPrefixEmpireEXPERIMENTAL=7.0 upgradeKeyPrefixEmpireFLEET
COMMAND=9.0 upgradeKeyPrefixEmpireFLEET SUPPORT=10.0
upgradeKeyPrefixEmpireION CANNONS=11.0
upgradeKeyPrefixEmpireOFFENSIVE 2=13.0
upgradeKeyPrefixEmpireOFFENSIVE=12.0
upgradeKeyPrefixEmpireOFFICER=4.0 upgradeKeyPrefixEmpireORDNANCE=14.0
upgradeKeyPrefixEmpireSUPPORT TEAM=15.0
upgradeKeyPrefixEmpireTITLE=3.0 upgradeKeyPrefixEmpireTURBOLASER
2=17.0 upgradeKeyPrefixEmpireTURBOLASER=16.0
upgradeKeyPrefixEmpireWEAPONS TEAM 2=19.0
upgradeKeyPrefixEmpireWEAPONS TEAM=18.0
upgradeKeyPrefixRebelDEFENSIVE 2=7.0
upgradeKeyPrefixRebelDEFENSIVE=6.0 upgradeKeyPrefixRebelFLEET
COMMAND=8.0 upgradeKeyPrefixRebelFLEET SUPPORT=9.0
upgradeKeyPrefixRebelION CANNONS=10.0
upgradeKeyPrefixRebelOFFENSIVE=11.0 upgradeKeyPrefixRebelOFFICER
2=5.0 upgradeKeyPrefixRebelOFFICER=4.0 upgradeKeyPrefixRebelORDNANCE
2=13.0 upgradeKeyPrefixRebelORDNANCE=12.0
upgradeKeyPrefixRebelSUPPORT TEAM=14.0 upgradeKeyPrefixRebelTITLE=3.0
upgradeKeyPrefixRebelTURBOLASER 2=16.0
upgradeKeyPrefixRebelTURBOLASER=15.0 upgradeKeyPrefixRebelWEAPONS
TEAM=17.0 upgradeRegex_DEFENSIVE 2=MC80\s+Assault
upgradeRegex_DEFENSIVE=Arquitens|ISD\s+(2|Kuat)|Assault\s+Frigate|CR90|MC30|MC75|MC80\s+(Assault|Command)
upgradeRegex_EXPERIMENTAL 2=Suppression
upgradeRegex_EXPERIMENTAL=Interdictor upgradeRegex_FLEET
COMMAND=Pelta|ISD\s+Cymoon upgradeRegex_FLEET SUPPORT=Gozanti|GR\-75
upgradeRegex_ION
CANNONS=CR90\-B|ISD\s+(2|Kuat|1)|Interdictor|MC75\s+Armored|MC80|Raider\s+2|Victory\s+2
upgradeRegex_OFFENSIVE 2=ISD\s+1|Quasar\s+Fire\s+1
upgradeRegex_OFFENSIVE=Gozanti|ISD|Interdictor|Quasar|Raider|Victory|Assault\s+Frigate|GR\-75|Hammerhead|MC75|MC80\s+Command|Pelta\s+Command
upgradeRegex_ORDNANCE 2=MC75\s+Ordnance
upgradeRegex_ORDNANCE=Hammerhead\s+Torpedo|Gladiator|ISD\s+Kuat|MC30|MC75|Raider\s+1|Victory\s+1|Pelta\s+Assault
upgradeRegex_SUPPORT
TEAM=Arquitens\s+CC|CR90|Gladiator|Interdictor|MC80|Pelta|Nebulon
upgradeRegex_TURBOLASER 2=ISD\s+Cymoon|MC80\s+(Star|Battle)
upgradeRegex_TURBOLASER=Arquitens|Assault\s+Frigate|CR90\-A|Hammerhead\s+Scout|ISD\s+(2|Cymoon|1)|MC30|MC75\s+Armored|MC80|Nebulon|Victory
upgradeRegex_WEAPONS TEAM 2=Quasar\s+Fire\s+2 upgradeRegex_WEAPONS
TEAM=Assault\s+Frigate|Hammerhead|Gladiator|ISD|MC30|MC75|MC80\s+(Battle|Star)|Quasar|Raider|Victory
For what it's worth, I'm experiencing much the same problem too. There's an older version of this Google Apps Script running and it's got around the same number of Properties. Going via the GAS interface I can't delete any of the properties. I've only just come across this problem so I haven't yet delved into a solution. The property I'm storing is a token for each user for a Service Account to utilise, so I'm hoping a programmatic purge of the tokens every x days will suffice. I'll post updates here.
In my case i couldn't save any file because an old linked library was deleted.

AS3 stack overflow?

Working with Arrays. I create objects on a Class base, push them into an Array, I have 2 buttons: one adds a Child and pushes it into the Array, second one Shifts Array and removes the Child. Also a function on my mouse, if I click an object, I define it's Array number, remove the Child and... well, not sure if successful but "delete Array[i];" where i is target's Array number. I can see Array.length in a text field every time I do something. Second button actually does remove an object from Array, the number decreases. But deleting a specified object from the Array, as well as Array.slice(i,1), doesn't reduce the Array length. So I'm afraid it may cause overflow. It's only Array, not sure, maybe it's fine to have over a million cells in an Array? Like if I make a game with meteor shower, meteors are removed from the screen, but the Array still has their cells. And if they appear like 30-50 per sec, it's obvious I may get memory problems in 20 minutes of running it. Well it's 60k so maybe I shouldn't worry as only graphics take much memory?
Still, I could use an advice on how to shift an object in a middle of an Array. Chosen one. How do I delete it as if it never was created, same as Shift does? (it does, right?)
Array.splice() will do most of the tricks. As you remove the meteor off screen, you can splice it out of the array, do like this:
var i:int=meteorArray.indexOf(meteorToRemove);
if (i>=0) meteorArray.splice(i,1);
You should not create a new object as a good practice if you are deleting other. Try recycling, or better said 'object pools'
You should figure out the number max of elements you may use at once. create a property 'active' on each and set it to true or false instead of creating/deleting. Then you can run the update on each object and update it only if necessary
For example:
var meteors:Array = [];
// create 500 meteors
for ( var i:int = 0; i < 500; i++ ) {
var meteor:Meteor = new Meteor();
meteor.active = false;
meteors.push(meteor);
}
// enable one meteor
meteors[0].active = true;
// in your update method:
for each (var meteor in meteors )
if ( meteor.active )
meteor.update();
Hope that helps.
Also you can add a helper method to get a meteor available:
function getMeteorAvailable():Meteor
{
for each (var meteor in meteors )
if ( !meteor.active )
return meteor;
}

Creating a user generated list in flash

I'm trying to create a flash application that will keep track of user generated values. The app should basically allow the user to input the name of the item and it's cost. The total costs should then be added up to show a total value to the user. I can probably figure out how to add the values together, but I'm not really sure how to allow the user to create a list and then allow the user to save it. Can anyone point me towards a tutorial or point me in the right direction?
I am using variables to add user inputed numbers to come up with a total. The first problem is that actionscript 3.0 does not allow variables for texts. I just converted it to 2.0 to fix this. The second problem, is when I test the app and put in my values and click submit, I get NaN in the total values field. Is there a reason why it wouldn't add the values?
Here is the code I used for the submit button:
on (release) {
total = Number(rent) + Number(food) + Number(travel) + Number(entertainment) + Number(bills);
}
Am I missing anything?
Can I give the input text instance names and then give them variables? How are some ways to go about this?
Thanks for the help!
Have an object array, say for example
var stack:Array = new Array();
Then push the item name and it's cost to that array when user inputs, like
stack.push({item:AAA, cost:xx});
So that you can generate the list whenever you want with that array.
You have to see how this works in code. A list in actionscript could be stored inside an array, vector, dictionary or even an Object.
Var myList:Array = [];
myList.push({name: "item 1", cost: 5 });
myList.push({name: "item 2", cost: 7.5 });
If you want to grab the 'product' of "item 1" from the list, you have to create a function for that, lets call it getProductByName
function getProductByName(name:String):Object
{
for each(var product:Object in myList)
{
if (product.name === name) return product;
}
return null; // no match found
}
You can call that function like this:
var product = getProductByName("item 1");
trace(product.cost); // 5
And you can alter the product, so lets make it more expensive
product.cost += 1;
trace(product.cost); // 6
Have fun! If you are using classes, you would create one for the product, with public name and cost, and in that case you'de better use a vector, to ensure working with the right type.
This is what fixed the issue for me in action script 3.0:
myButton.addEventListener(MouseEvent.CLICK, addThem);
function addThem(e:MouseEvent)
{
totalField.text = String ( Number(field1.text) + Number(field2.text) + ....);
}
I also had to name the instances appropriately.

How can I remove a contact CompleteName.Title with EWS managed api v1.1?

Using EWS managed api v1.1, I can successfully save/set the contact "Title" or honorific (if you prefer) to a non-empty value, but I can't figure out how to remove or set it back to an empty string/null.
I've tried to set an empty value and I've tried to remove the extended property. Here is relevant code.
var titleDef = new ExtendedPropertyDefinition(0x3A45, MapiPropertyType.String);
// works when set to a non-empty string value
ewsContact.SetExtendedProperty(titleDef, "Mr.");
// throws null argument exception when set to String.Empty or null
ewsContact.SetExtendedProperty(propDefinition, String.Empty);
// isRemoved is equal to false and the value doesn't change
var isRemoved = ewsContact.RemoveExtendedProperty(titleDef);
I've also tried to use a different overload on the ExtendedPropertyDefinition as mentioned in this very similar question, but it didn't change my end result for removing the property. I'm not sure I understand the difference in the two signatures for the constructor.
var titleDef = new ExtendedPropertyDefinition(new Guid("{00062004-0000-0000-C000-000000000046}"), 0x3A45, MapiPropertyType.String);
// isRemoved is equal to false and the value doesn't change
var isRemoved = ewsContact.RemoveExtendedProperty(titleDef);
Brute Force Work-Around
I suppose I could take a complete copy of the contact (without the title) and delete the original, but that seems a bit over the top and would probably cause other bugs.
EWS lets you assign Extended Properties without first binding them. However, to remove an Extended Property - you need to include it in your initial binding call PropertySet. The following worked for me...
var titleDef = new ExtendedPropertyDefinition(0x3A45, MapiPropertyType.String);
Contact contact = Contact.Bind(service, id, new PropertySet(titleDef));
contact.RemoveExtendedProperty(titleDef);
contact.Update(ConflictResolutionMode.AutoResolve);
It is also strange that you can retrieve the Title as a first-class property, but you cannot assign it (since it's a complex type). They could have made this easier for us.
var title = contact.CompleteName.Title;

In LINQ to SQL how can I make it so I can add items to a collection of an entity without saving the entity first?

var e1 = new E1();
e1.e2s.Add(new e2()); //e2s is null until e1 is saved, i want to save them all at the same time
context.e1s.imsertonsubmit(e1);
context.submitchanges();
The sub items will be saved along with the main item, and even identities will be set properly, if you give your DataClasses an association between these classes.
You do this by adding LoadOptions to your O/R-Designer DataClasses like this:
MyDataContext mydc = new MyDataContext();
System.Data.Linq.DataLoadOptions lo = new System.Data.Linq.DataLoadOptions();
lo.LoadWith<E1>(p => p.e2s);
mydc.LoadOptions = lo;
This way LINQ will take care of adding the sub-items, you don't need to InsertOnSubmit every one by itself.
A side effect: upon loading the item, the subitems will be retrieved, too.
Well - I don't know if your initial code block would work, but I'm guessing you have to mark your new e2 as insert on submit. Thus:
var e1 = new E1();
var e2 = new e2();
e1.e2s.Add(e2); //e2s is null until e1 is saved, i want to save them all at the same time
context.e1s.insertonsubmit(e1);
context.e2s.insertonsubmit(e2);
context.submitchanges();
there we go, apparently when you create another ctor, you have to actually call the no arg ctor in order for the stuff in the ctor to happen