VBA script to combine all records in a sub-form into a usable string
I am using the Outlook 15.0 Object Library to create emails and appointments.
I have a form that contains event information and subform that contains event participants (a related table).
Right now I am able to click a button that will take information from the Event table and one selected record at a time from the participants table. Some of the participants are instructors, some are staff. I only want to list instructors.
That code looks something like this:
.body = "Participants: <ul><li> " & [Forms]!MainForm!SubForm.Form![Participant]
This means I have to create three emails or manually type additional details.
What I am looking to do is do some sort of loop to combine these before inserting them into the .body code. Below is a sketch of what I want to happen, but again -- I'm not sure where to begin.
Dim Instructors as String
If [Subform].[Type] = "Instructor" Then
Add to Instructors & "</li><li>"
End if
.body = "Participants: <ul><li> " & Instructors & "</li></ul>"
You might like to take a look at the file Concat.zip in my public databases folder at:
https://onedrive.live.com/?cid=44CC60D7FEA42912&id=44CC60D7FEA42912!169
If you have difficulty opening the link copy its text (NB, not the link location) and paste it into your browser's address bar.
This little demo file includes a solution for concatenating values from a related table using the very efficient GetString method of the ADO recordset object to concatenate values. As the example it uses data from Northwind. In my file the function
is called in a report, but you could call it in your code to build a list of participants as a string expression. If you want the participants listed on separate lines use the left hand column of my report as the example of how to call the function;
for a comma separated list use the right hand column.
Allen Brown also provides a concatenation function at:
http://allenbrowne.com/func-concat.html
which I believe loops through a DAO recordset to build the list.
Ken Sheridan, Stafford, England
Similar Messages
-
How do I hide objects in all instances of a sub-form?
I have a list of objects in a sub-form. They are hidden or made visible depending on the selection of a drop-down menu outside the sub-form. It works correctly for the first instance, but objects that are supposed to remain hidden become visible in all subsequent instances of the sub-form.
How do I make the objects remain hidden in all instances of the sub-form?I think you want to move all the code from the change event of form1.EXP_Sample_Form.Identifier.Who.LOB_List.LOB_List to the calculate event of form1.EXP_Sample_Form.Bottom_of_Form.
Which would then look like;
switch (Identifier.Who.LOB_List.LOB_List.rawValue)
case "AmeriHealth Caritas":
PCPInfo.Docs.SiteVisit.presence = "hidden";
PCPInfo.Docs.Comments_SiteVisit.presence = "hidden";
PCPInfo.Docs.SiteVisit_Received.presence = "hidden";
PCPInfo.Docs.PanelAttestation.presence = "hidden";
PCPInfo.Docs.Comments_PanelAttestation.presence = "hidden";
PCPInfo.Docs.PanelAttestation_Received.presence = "hidden";
break;
Here is your form with this suggestion made, https://workspaces.acrobat.com/?d=koCEYxi-59F7n5iyIoMhGQ
Bruce -
Copy all records in a tabular block into another block..
hi guys,
i am in a situation and have to solve it as early as possible.
I have created 2 tabular blocks on my form. Lets say i have created emp block with table emp and emp1 block with the same table emp. I have 2 blocks with same fields. I have execute query in block 1 that is emp and now i want to copy all records of emp block in emp1 block.
i have to do this thru code.
pliz help how to copy records in another block with same fields.
its urgent.
regards, Imran BaigTry with the following code.
If it works let me know.
Regards,
shalauddin.
from Bangladesh.
begin
GO_BLOCK('B2');
first_record;
LOOP
GO_BLOCK('B1');
LAST_RECORD;
IF :SYSTEM.LAST_RECORD='TRUE' THEN
NEXT_RECORD;
:B1.ID:=:B2.ID;
NEXT_RECORD;
GO_BLOCK('B2');
ELSE
:B1.ID:=:B2.ID;
NEXT_RECORD;
GO_BLOCK('B2');
END IF;
IF (:SYSTEM.last_record='TRUE') THEN
EXIT;
ELSE
NEXT_RECORD;
END IF;
END LOOP;
GO_BLOCK('B1');
END; -
How to save all records in the Tabular form page temoprarily
Hi All,
I am very new for HTML DB. I created 5 tabular form using HTML DB Wizard. I want that whenever I open any tabular form page and click the add row button in that page then I should add as many record as we need but it should not save in the database but want to save all the page record temporarily in the page. When save button should click then it should save in the database. Can anyone suggest how to do in stepwise. It will be a great help for me.
Thanks.
AmitHi,
Anyone, can help me with this scenario.
Brgds,
Mini -
Hi
I'm brand new to Visual Basic really - you will be able to tell that I am a complete beginner. I wouldn't be posting here but I had tried asking other Forums but have not got any responses.
This is the problem:- I've found a basic VB script to copy attachments within Outlook 2000 Inbox to the c:temp folder when a new email arrives in. When I debug the script in Outlook > Tools > Macros , it just seems to loop round and round within the
top function called Application_Startup () and never attempts the objInbox_ItemAdd() function which is the important part. Please can anyone say what is wrong.
I'm putting all this code within Project1 > Microsoft Outlook Objects > This OutlookSession - I bet I'm putting all this code in the wrong place aren't I? Please help anyone.
Dim WithEvents objInbox As Outlook.Items
Private Sub Application_Startup()
Set objInbox = Session.GetDefaultFolder(olFolderInbox).Items
End Sub
Private Sub objInbox_ItemAdd(ByVal Item As Object)
If Item.Class = olMail Then
If Item.Attachments.Count > 0 Then
Dim objAttachments As Outlook.Attachments
Set objAttachments = Item.Attachments
For Each objAttach In objAttachments
' Does not handle duplicate filename scenarios
objAttach.SaveAsFile "C:\temp" & objAttach.FileName
Next
Set objAttachments = Nothing
End If
End If
End Sub
Also, I've set the Security to Low within Outlook > Tools> Macros > Security and a bit baffled why this won't run.
Just for info, I got this VBScript solution from:-
Outlook Visual Basic for Applications Rules
Kind Regards
Matt
p.s I'm stuck with Outlook 2000 due to a limitation with some Legacy software that my company is still using.Thanks jrv.
At the moment - I don't have the time to learn VBA better along with learning the other things I have an intested in already (e.g. PowerScript) - My customer has an outstanding fault which need fixing urgently. I've spent about 5 hours so fa trying to get
a VBA script to work withing Outlook but to no avail. I might ask around my company to see if any one else can help or post this on a non-Microsoft forum I think.
Cheers all the same
Matt
So you sold a job to do something you do not knowhow to do. You are getting paid. It is your job to learn or to hire someone with the skills you have sold. We cannot produce custom scripts for an obsolete version of Outlook 2000..
O2000 is almost 15 years old. It is not secure as no security patches have been released for it for almost 10 years. It is old technology which none of us care to remember unless you want to pay us for the assistance.
Here is the link to the instructions in th KB that you completely ignored:
http://support.microsoft.com/kb/235852/EN-US
It shows you exactly how to do this in Outlook 2000. You must read all of the instructions carefully. YOu must try all example code and be sure you understand how it works. Post all issues with how to use VBA in the Outlook VBA developers
forum AFTER you have tried that code and have a specific question and not just a requirement for someone to fix this for you.
The code in the article is explicit to Outlook 2000. The code you are using is only usable in Outlook 2002 and later., You must follow the examples for Outlook 2000 as outlined in your original article.
If you want to be a technician you need to learn all of these things. Just knowing how to install a PC is not sufficient if you are going to be a contractor.
VBA is VBA. Posting here will not change that. This is an Admin scarping forum and not an office VBA forum. VBA is NOT VBScript. No matter how much it looks like VBScript it is not.
You cannot just copy VBScript into a VBA module and expect it to work.
You have sold the job of a programmer and Outlook developer with no skills in that area. Is that fair to your customer?
There are hundreds of skilled developers who have spent good money and time learning to do these things. You cannot just past some things you found on the Internet into a file and ask someone to fix it for you.
Start by learning the difference between script and VB. Next you need to learn what an event is and how it is generated. The code you posted does nothing in Outlook because it is not Outlook code.
No. I am not picking on you. I am trying to get you to wake up and spend time learning your profession. It is a lot of fun and actually pretty easy but only if you do your homework.
¯\_(ツ)_/¯ -
Script for combining multiple documents?
hi there,
well I think there's been a lot of discussion going towards this topic. My concerns aren't quite lining up with the topics. We using a script for placing images, and instead of going document to document...I would like to combine all the indd documents...there's usually at least 24...and to import NOT as pdf's, just as individual pages within the one document...insert my images using the other script...and then later choosing to re-export the pages as individuals. With ascending order of page numbers in the correct sequence they were brought in as.
thanks for the help.-Printing by folder only helps when I need to run one copy of the files, typically I need to print multiple copies or save them for future printing. Also I have had errors printing via that method before because it will sometimes overload the printer queue.
-It would be great if clients always provided print ready documents, but that is usually not the case and I have to correct it which is why I am here asking how to do this.
And if you can not do that then you need to insert a blank page into the files with an odd number of pages.
Right. That is what I am looking for; something to automate inserting a blank page into files that have an odd number of pages WITHOUT knowing the documents page counts before hand and WITHOUT having to manually insert blank pages. -
Calculate % of answers across all records in a list
I have a list that gathers information from users. I want to calculate the percentage of a given answer across all records. To keep things simple, consider the following example.
A list called "Shirts" contains 3 choice fields:
1) Color: with choice options of Red, Blue or Green
2) Size: with choice options of Small, Medium or Large
3) Style: with choice options of T-Shirt, Button-up or Long-Sleeve
At the bottom of the page I want to display what percentage (across all records) that the shirt color chosen was Blue.
So if I had 10 records in the list and 4 of those listed color as Blue, the bottom of the main view page would show: Blue = 40%. This percentage would then update as more records are added. ie - an 11th record is added that does not choose Blue so the percentage
would then display as 36%.
I know how to do calculations like this within a given list record but I need a way to keep a running calculation across all records that updates as new records are added.Hi Mike,
As a workaround, you can use JavaScript to retrieve items value from a List and calculate the value according to your requirement, then display the result in the list
view page.
Here is a link about how to retrieve items from a List using JavaScript:
http://msdn.microsoft.com/en-us/library/office/hh185007(v=office.14).aspx
I modify the script a bit in the link above, you can apply the script below to your list view page, it will display the percentages of each value as you need:
<script type= text/javascript>
_spBodyOnLoadFunctionNames.push("ready");
function ready()
ExecuteOrDelayUntilScriptLoaded(retrieveListItems, "sp.js");
function retrieveListItems()
var clientContext = new SP.ClientContext.get_current();
var oList = clientContext.get_web().get_lists().getByTitle('List1');
var camlQuery = new SP.CamlQuery();
this.collListItem = oList.getItems(camlQuery);
clientContext.load(collListItem);
clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded), Function.createDelegate(this, this.onQueryFailed));
function onQuerySucceeded(sender, args)
var blueCount = 0, redCount = 0, yellowCount = 0;
var listItemEnumerator = collListItem.getEnumerator();
var sum = collListItem.get_count();
while (listItemEnumerator.moveNext())
var oListItem = listItemEnumerator.get_current();
if(oListItem.get_item('Color') === 'Blue')
blueCount += 1;
if(oListItem.get_item('Color') === 'Red')
redCount += 1;
if(oListItem.get_item('Color') === 'Yellow')
yellowCount += 1;
document.getElementById('blueSpan').innerHTML = "Blue: " + blueCount/sum*100 + "%";
document.getElementById('redSpan').innerHTML = "Red: " + redCount/sum*100 + "%";
document.getElementById('yellowSpan').innerHTML = "Yellow: " + yellowCount/sum*100 + "%";
function onQueryFailed(sender, args)
alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());
</script>
<p id="blueSpan">Blue:</p>
<p id="redSpan">Red:</p>
<p id="yellowSpan">Yellow:</p>
About how to add JavaScript into SharePoint page:
http://blog.cloudshare.com/2012/10/29/how-to-insert-custom-javascript-code-in-sharepoint-2013-pages-part-i/
Best regards
Patrick Liang
TechNet Community Support -
Script to pull all connections from one IP out of DPS access logs...
I need an efficient script to pull all of the connections for 2 IP's (or match the first two octets of the IP will cover both addresses also) from multiple DPS access logs out and write them to a file.
The current one-liner I've been using doesn't work well with multiple access log files. So I tried combining multiple logs into one access log, and then trying to parse that large log file (around . The problem is, I am now getting the error: "bash: /usr/bin/egrep: Arg list too long", which is because it takes all of the connection numbers and builds a grep with them.
Here is the one-liner I've been using:
FILTER='client=192.168.1.1|client=192.168.2.1'; FILE='access.*'; for j in $FILE; do unset CONN; for i in `egrep -h "$FILTER" $j | awk '{print $8}'`; do CONN="$CONN|$i"; done; if [ -n "${CONN+x}" ]; then egrep -h $CONN $j; fi; done | sort -t '/' -k2,2M -k1n
Is there a faster and more efficient way to pull out all of the connections from one or more IP's in access logs? I would think someone out there would have written something to do this?
Thanks everyone!!!
Edited by: keesor on Aug 17, 2011 2:49 PMIt could be as simple as
lgrep -O conn <IP> access
If you have more logs you can cat them and pipe the output to lgrep in a pipeline, like:
cat access.1 access.2 ... access.n | lgrep -O conn <IP>
Just make sure that the logs are listed in sequence. The script won't produce reliable results if the log is non-sequential. -
VBA script for automatically indexing topics
A big disadvantage with InDesign's indexing system is that you cannot automatically index all occurences of topics currently in the index.
Instead, you have to find an occurence of each topic in the document itself and go to the Index menus and then click New Page Reference...Add All, for each index topic individually.
To get around this, I have been trying to produce a VBA script to automatically index all occurrences in a document of the topics currently in the document index.
I have been using the MS Excel VBA development environment but find the definitions of the object model in the Excel VBA browser rather inadequate and ambiguous .
Is there a more thorough reference work for these?
The plan was to start by taking each individual topic in the index which I tried to access with something along the lines of:
MyDocument.Index.Topic(1)
This hasn't worked.
The plan then was to take each index topic and use it to find an occurence in the document of that topic and then use that occurence to invoke the New Page Reference...Add All option to index all occcurences of that selected term, using something like:
MyDocument.PageReferences.Add
Again, without success.
Any guidance or suggestions would be appreciated.Dear Peter,
Many thanks for your posting, that was very helpful.
This is the state of the script so far (I have added a large number of MsgBox entries - these aren't needed, they are just for debugging purposes during development):
'VBA script which tries to work through all of the topics in the index and automatically index each occurence of them in the current text frame:
main
Function main()
Set MyInDesign = CreateObject("InDesign.Application.CS4")
If MyInDesign.Documents.Count > 0 Then
Set MyDocument = MyInDesign.ActiveDocument
Set MyPage = MyDocument.Pages.Item(1)
Set MyTextFrame = MyPage.TextFrames.Item(1)
Set MyStory = MyTextFrame.ParentStory
Set MyIndex = MyDocument.Indexes(1)
Set MyTopics = MyIndex.AllTopics
MyIndexesCount = MyDocument.Indexes.Count
MsgBox "Current indexes Count: " & MyIndexesCount
MyIndexTopicsCount = MyTopics.Count
MsgBox "Current index topics Count: " & MyIndexTopicsCount
For i = 1 To MyTopics.Count Step 1 'work through the topics
MyIndexTerm=MyTopics(i)
MsgBox "Current indexes Topic: " & MyIndexTerm
'search for MyIndexTerm :
'Clear Find preferences:
MyInDesign.FindTextPreferences = idNothingEnum.idNothing
'Set up search paramaters:
If MyIndexTerm <> "" Then
MyInDesign.FindTextPreferences.FindWhat = MyIndexTerm
'Set search options:
MyInDesign.FindChangeTextOptions.CaseSensitive = False
MyInDesign.FindChangeTextOptions.IncludeFootnotes = False
MyInDesign.FindChangeTextOptions.IncludeHiddenLayers = False
MyInDesign.FindChangeTextOptions.IncludeLockedLayersForFind = False
MyInDesign.FindChangeTextOptions.IncludeLockedStoriesForFind = False
MyInDesign.FindChangeTextOptions.IncludeMasterPages = False
MyInDesign.FindChangeTextOptions.WholeWord = False
'Search for the string:
Set MyFoundItems = MyDocument.FindText 'this ought to be limited to the Story, not the Document eg MyStory
MsgBox "Found index terms:" & MyFoundItems.Count
For j = MyFoundItems.Count To 1 Step -1
MyTopics(i).PageReferences.Add MyFoundItems(j)
Next
'Clear preference:
MyInDesign.FindTextPreferences = idNothingEnum.idNothing
'Having found it, add page reference:
'MyDocument.PageReferences.Add
Else
MsgBox "No search term specified"
End If
Response=MsgBox ("Continue?", vbYesNo)
If Response = vbNo then
Exit For
End If
Next
'Set up Index options:
MyIndex.IndexOptions.Title = "Index"
MyIndex.IndexOptions(1).TitleStyle="Chapter Head"
MyIndex.IndexOptions(1).ReplaceExistingIndex = True
'Generate the index:
MyIndex.Generate
Else
MsgBox ("Please open a document, select an object, and try again.")
End If
End Function
There are a couple of problem areas still:
1. Index terms appear to be added irrespective of whether or not that particular page reference already exists in the index.
This can result in duplicate page references under each topic - especially if the script is run several times.
Is there any way of avoiding these duplicate references?
2. I haven't yet suceeded in getting the script to generate the index - so far I've had to do it manually after the script has run.
The problem lies somewhere in the code to set up the index options and then generate the index.
3. It might be useful to be able to limit the indexing to the curent story rather than the whole document - but I haven't yet got it to do that.
Best wishes. -
Selecting distinct combination of records
Hi Expart ,
I have table fields like function ,tcode,objects,fields,from ,to ,user like that in which except user all r primary key fields but i want Number of unique Function-Tcode-Object combinations when select the data.
i am doing like that
SELECT COUNT( distinct FUNCTIONID TCODE OBJECT)
FROM /PSYNG/FUNCTTRAN
INTO L_FUN_TCD_OB
WHERE VRSIO = P_VRSIN.
but it will give an error
plz help me to get no of this combination of records .
Thanks in advance .
Tsenhi
u can write code like this
SELECT distinct FUNCTIONID TCODE OBJECT
FROM /PSYNG/FUNCTTRAN
INTO table it_L_FUN_TCD_OB
WHERE VRSIO = P_VRSIN.
data: var type sy-tabix.
describe table it_L_FUN_TCD_OB lines var.
L_FUN_TCD_OB = var.
refresh it_L_FUN_TCD_OB.
Regards
Sajid -
Sorting all records in datagrid
Hi All,
I have a datagrid with pagination. On default or on click of the sort arrow of a particular column in the grid it sorts only the current page data. my requirement is it should sort across all records returned in array collection not only the records for the current page. Please share the working sample code.
Thanks,
RavishaTry this code:
<?xml version="1.0"?>
<!-- dpcontrols/adg/SimpleHierarchicalADG.mxml -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" creationComplete="init()" layout="vertical">
<mx:Script>
<![CDATA[
import mx.events.DataGridEvent;
import mx.collections.ArrayCollection;
include "dgData.as";
[Bindable]
private var dp:ArrayCollection;
private var offset:int = 0;
[Bindable]
private var pageNum:int = 0;
[Bindable]
private var maxPages:int;
[Bindable]
private var dgRowCount:int = 9;
private function init():void
dp = new ArrayCollection();
maxPages = dpHierarchy.length / dgRowCount;
filterPage();
private function navToPage(pageOffset:int):void
pageNum += pageOffset;
if (pageNum < 0)
pageNum = 0;
if (pageNum > maxPages)
pageNum = maxPages;
offset = pageNum * dgRowCount;
filterPage();
private function filterPage():void
dp.source = dpHierarchy.source.filter(function callback(item:*, index:int, array:Array):Boolean
return (index >= offset && index < offset + dgRowCount);
private function doSort(evt:DataGridEvent):void
var sortDescending:Boolean = evt.itemRenderer.data.sortDescending;
!sortDescending ? dpHierarchy.source.sortOn(evt.dataField, Array.NUMERIC | Array.DESCENDING) : dpHierarchy.source.sortOn(evt.dataField, Array.NUMERIC);
filterPage();
]]>
</mx:Script>
<mx:DataGrid dataProvider="{dp}" rowCount="{dgRowCount}" sortableColumns="true" headerRelease="doSort(event)">
<mx:columns>
<mx:DataGridColumn headerText="ID" dataField="id"/>
<mx:DataGridColumn headerText="First prop" dataField="firstProp"/>
<mx:DataGridColumn headerText="Second prop" dataField="secondProp"/>
</mx:columns>
</mx:DataGrid>
<mx:HBox horizontalAlign="center">
<mx:Button label="Prev page" click="navToPage(-1)"/>
<mx:Label text="{pageNum + 1}/{maxPages + 1}" textAlign="center" width="60"/>
<mx:Button label="Next page" click="navToPage(1)"/>
</mx:HBox>
</mx:Application>
You have to add the following file to your source folder:
Hope you can work it out with this
Dany -
UCCX Scripting Question- combining multiple scripts into one -Transfers/subflows
I need to separate an existing call center into two because their hours are different and the main lines have separate DIDs.
The two separate call centers must have the same agents and same queues, including Agent Personal Queues as Menu options. Callers need to be able to choose to go to either the Main Queues, or listen to another menu that allows them to select and option to be sent to a personal queue
I have three separate scripts, CCA, CCB, and Agent Personal Queue, same queues, same switch (calledNumber) with the same trigger(DNs) and I was about to create three separate applications, but then realized the triggers can only point to one application
What is the best way to set this up?
Option A
Script A (CCA )- Has all the "Switch-(Called Number) with all the trigger
Script B -Has no Switch, just Transfer to extension(and then the call goes out to the trigger)
Script C - is the Personal Queue Script
Option B
Combine all three scripts into one-separate the TOD logic, have the same queues and menus beneath each call center and Personal Queue tree, is going to be a really large fileHello-
I would likely use a single script for your application. That being said looking at your screenshot it looks like your script could use some clean up and consolidation.
DJ -
Powser Shell Script to Purge Computer Records from SCCM
Hello!
I have built a collection in Configuration Manager to bring in a list of computers that have duplicate names. Here is the query that I am using.
select R.ResourceID,R.ResourceType,R.Name,R.SMSUniqueIdentifier,R.ResourceDomainORWorkgroup,R.Client from SMS_R_System as r full join
SMS_R_System as s1 on s1.ResourceId = r.ResourceId full join SMS_R_System as s2 on s2.Name = s1.Name where s1.Name = s2.Name and s1.ResourceId != s2.ResourceId
I am building a PowerShell Script to obtain the names of the computer resources stored in the above SCCM 2012 collection and place them in a variable. Next,
I want to obtain the computer resources (e.g., ddr records) and store them in a 2ed variable using the first variable to pipe in the data. I am using a “ForEach” looping construct to accomplish this. Lastly, I want to purge the computers records from the Configuration
Manager database that are stored in the second variable which came from the computers names of the specified SCCM collection. I am attempting to use this line of code within my loop to purge the computer records from SCCM:
$compObject.psbase.syncroot | % { $_.psbase.delete()
Here is a
blog I found suggesting this line of code.
What I have discovered is rather interesting. My script works as intended, but even though the correct records ARE
being purged. The above line of code is returning an error.
You cannot call a method on a null-valued expression.
At line:18 char:35 + $compObject.psbase.syncroot | % { $_.psbase.delete() }
+ ~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
I have a few questions:
Does anyone know why this is occurring?
Is there a different approach or code I should be using instead to purge the collected data?
Here is my full script:
#// required parameters
$SCCMServer
= "MySiteServer"
$sitename
= "PS1"
$collectionID
= "PS1009c8"
#// Obtain collection members from $collectionID
$SMSClients
= Get-WmiObject
-Query "SELECT * FROM SMS_FullCollectionMembership WHERE CollectionID='$collectionID' order by name"
-ComputerName $SCCMServer
-Namespace "ROOT\SMS\site_$sitename"
#//looping construct to loop through all the colection members
ForEach ($SMSclient
in $SMSclients) {
#// Loads computer records one at a time into $compobject variable using a ForEachloop to be deleted
$compObject
= get-wmiobject
-query "select * from SMS_R_SYSTEM WHERE Name='$($smsclient.name)'"
-computername $SCCMServer
-namespace "ROOT\SMS\site_$sitename"
#// Delete’s computer objects one at a time in $compObject variable from CM12 database
$compObject.psbase.syncroot
| % {
$_.psbase.delete() }
--TonyDaniel
Have you ever used Orchestrator to kick off your Powershell scripts? I am using System Center 2012 R2 Orchestrator, and trying to use the "Run .Net Script" action to launch my Powershell code, but the process is failing. When I run the code
from within PowerShell and RunBook Tester the code executes as it should. When I run it from the RunBook I receive this error:
Exception calling "Delete" with "0" argument(s): "Generic failure "
Just curious if you had any thoughts why my code was blowing up in an Orchestrator RunBook when it works fine within PowerShell? My full code is below.
#// required parameters
$SCCMServer = "MySiteServer"
$sitename = "PS1"
$collectionID = "PS1009c8"
#// Obtain collection members from $collectionID
$SMSClients = Get-WmiObject -Query "SELECT * FROM SMS_FullCollectionMembership WHERE CollectionID='$collectionID' order by name" -ComputerName $SCCMServer -Namespace "ROOT\SMS\site_$sitename"
#//looping construct to loop through all the colection members
ForEach ($SMSclient in $SMSclients) {
#// Obtains and deletes the SCCM computer records one at a time using a ForEachloop
Get-WmiObject -query "select * from SMS_R_SYSTEM WHERE Name='$($smsclient.name)'" -computername $SCCMServer -namespace "ROOT\SMS\site_$sitename" |
ForEach-Object { $_.Delete() } -
How to show all records by default on search result page?
Hi
I am trying to make a search page that would execute the search in the database based on one or more field constraints.
(Using MySQL,PHP)
I have 2 columns in the database "vm_ip" (primary key) <IP address>, "Operating_System" <Any, Windows, Solaris, AIX>
need to search vm_ip based on other two fields.
PROBLEM: Need to show all the record when I select "Any" in the Operating_System drop down menu.
<p>Operating System:
<select name="os_select" id="os_select">
<?php
$os_count=1;
foreach($os_type as $value) //(os_type is array with possible values of OS)
echo "<option value=".$os_count.">".$value."</option>";
$os_count++;
?>
<option value=" " selected="selected">Any</option>
</select>
</p>
this code POSts NULL value to the search page.
Below code is of recordset on search page
$varOS_virtual = "Operating_System"; // recordset variable set to same as column name (default value)
if (isset($_POST['os_select'])) //this should not be true
$varOS_virtual = $_POST['os_select'];
mysql_select_db($database_xyz_db, $xyz_db);
$query_virtual = sprintf("SELECT table.VM_IP FROM table
WHERE table.Operating_System=%s", GetSQLValueString($varOS_virtual, "int"));
$virtual = mysql_query($query_virtual, $xyz_db) or die(mysql_error());
$row_virtual = mysql_fetch_assoc($virtual);
$totalRows_virtual = mysql_num_rows($virtual);
I expected the 'os_select' field to be null and default value of Operating_System to be "Operating_System" so that the Query shows all records.
But instead the value being passed in the Query is "0". and no records are shown.
What can I do to show all records?
As probably obvious I am new to php/MySQL so all the help is most welcomed .
ThanksHi
Thanks for the prompt reply but this does not solve my problem.
First thing I appologise for giving you incorrect info. Actually I have many more constraints on the search apart from OS.
Didn't think I would get single constraint specific ans.
Here is what all i tried and problems I faced:
1. I cannot use seperate queries cause I have around 7-8 other constraints on the search.
2. I cannot play around with the Record set code. For some reason even if I mess with it a little bit Dreamweaver stops recognising the recordset. for eg i tried the below code:
$query_virtual = sprintf("SELECT table.VM_IP FROM table WHERE
table.Operating_System=%s ,($_POST['os_select']=="")? TRUE:GetSQLValueString($varOS_virtual, "int"));
this ran well for the first time, and then the record set was screwed up. kept on asking me to "Discover" the links, which it couldn't do.
3. take a look at this code:
$varOS_virtual = "Operating_System";
if (isset($_POST['os_select'])) {
$varOS_virtual = $_POST['os_select'];
$varState_virtual = "State"; //second constraint
if (isset($_POST['state_select'])) {
$varState_virtual = $_POST['state_select'];
mysql_select_db($database_xyz, $xyz);
$query_virtual = sprintf("SELECT table.VM_IP FROM table AND table.Operating_System=%s AND State=%s",
GetSQLValueString($varOS_virtual, "int"),GetSQLValueString($varState_virtual, "int"));
$virtual = mysql_query($query_virtual, $xyz) or die(mysql_error());
$row_virtual = mysql_fetch_assoc($virtual);
$totalRows_virtual = mysql_num_rows($virtual);
here on passing NULL value for "Any" GetSQLValueString($varOS_virtual, "int") functions returns NULL and though the Default value of
varOS is set to 'Operating_System" query takes NULL value only which when executed shows no records.
My problem majorly revolves around how to put something like "WHERE Operating_System= Operating_System" OR "WHERE Operating_System= TRUE" in the query, when passed through variable they are sent as Strings or NULL.
Thats why WHERE 1=1 also doesnt work, because it has "WHERE Operating_System= NULL" in AND.
Logically when NULL is passed default value of variable should comeinto picture, but tha isnt happening.
Thanks again for answering. hope I was able to explain my problem. -
Display all records from 4 select list
Hi,
trying to associate 4 select list where i could display all records from a list linked to an other list.
1./ Created an item for each select list
P1_employee_name
P1_departments
P1_employee_type
P1_locations
2./Set both null and default values to '-1' for each item
3./Associated these items to source columns in the Region:
where employee_name=:P1_employee_name
or :P1_employee_name ='-1'
and departments=:P1_departments
or :P1_departments ='-1'
and ......
When running the report, couldn't display all records from a given list associated to an other list.
e.g: Display all emp and type of emp for sales dept in Paris.
Thks for your helpI believe the issue is that you need to group your predicates such as:
where (employee_name=:P1_employee_name
or :P1_employee_name ='-1')
and
(departments=:P1_departments
or :P1_departments ='-1')
Also, if you are not already using the "select list with submit" type items, these work great for this case as the page will be submitted when the user changes the value of employeenam and the report will then reflect this change.
Maybe you are looking for
-
Can no longer transfer pictures, have to log in to every thing every time firefox opens.
-
Before I buy "numbers" can anyuser advise me from their experiences if I'll be able to open password protected excel files in iphone 4S?
-
Driver for Intel Corp. Intel(R) PRO/Wireless 2200BG in Solaris 10 x86
Hi Folks, I bought a Laptop with the NIC mentioned in the Subject. After installing Solaris 10 x86 I'd like to install a driver for this card. Can someone of you tell me how, or point me to a good documentation? Cheers Sven
-
I am trying to locate the zfs packages in the 1/06 Solaris 10 release. Is it hidden under another name or did it not make the release?
-
How do i know if iCloud backed my stuff up?
Before the ios8 update i restored my ipad. Im not sure if i had stuff backed up in icloud but in the icloud settings on my ipad i had photo and back up on. I logged onto the icloud website but i don't see anything saying i backed up photos.