Pasting choice from a applescript list into any application - applescript

I am new to applescript, and am only here because I need a solution.
I want to be able to choose from a list and have the information go into a box, no matter which app.
I have a script that gives me a list and I can select.
But dont know how to get it to paste into the area or box.
set emailaddress to {"email address 1", "email address 2", "email address 3", "email address 4"}
set emailaddress to choose from list emailaddress with prompt "Select your Email:" default items "email address 1"
emailaddress
--> Result: email address 1
Thanks
Larry

First of all the result is {email address 1} because choose from list returns a list.
To be able to paste the address put it on the clipboard
set addresses to {"email address 1", "email address 2", "email address 3", "email address 4"}
set emailaddress to choose from list addresses with prompt "Select your Email:" default items "email address 1"
if emailaddress is false then return -- catch the case that the user presses the Cancel button
set the clipboard to item 1 of emailaddress -- flatten the list
Then you can press ⌘V

Related

Update a cell in Excel Sheet using Power Automate

I'm trying to update the "Email Sent" column once an email has sent. Once an email has been sent I want it to say "Sent" instead of "No"
I'm using the "update a row" action however, can't seem to have it updated. I'm not sure what I should enter for the "Key Value" because email can be sent for multiple rows at once. This is what I have so far but it is not working:
My Excel table:
When you use "Update a row", you need to specify a key column (the one with a unique id or value) so Power Automate can search a single row and update it.
Field "Key Column" is the column name where said ID is stored.
Field "Key Value" is the value to search for.
For example, in the following table:
Mentor ID
Email
Email_Sent
A001
someone#gmail.com
No
A002
someoneelse#gmail.com
No
If you wanted to update the first row, you'd need to specify Key Column = Mentor ID, and Key Value = A001.

Best way to define subpredicates with predicateEditor from users' perspective

I am wondering how to use NSPredicateEditor to define subpredicates from out the user's perspective - and how to implement it.
Suppose we have a simple NSPredicateEditor created in IB as shown below.
It has 2 items to choose from:
lastname
address.street
So we can create a predicate like
lastname ==[c] "Smith" OR lastname ==[c] "Miller" OR address.street ==[c] "3rd Avenue"
Now, if I want to have only Millers selected, living in the 3rd Avenue, what can I do ? I would prefer to have a button like "s" to create a subpredicate just below the selected line (Miller) to get this result:
lastname ==[c] "Smith" OR (lastname ==[c] "Miller" AND address.street ==[c] "3rd Avenue")
Unfortunately, there is no other button than + or - for each item (row).
Is there any other way ? Can it be done with low programmatically effort ?
Set "Nesting" of the predicate editor to "Compound". At runtime: Press the Option Key and the + button will change to … for adding a compound row.

Cannot display correct records in unbound form in Access 2013

I have one Table called tblEmployees - ID, First, Last. One unbound form called frmSearch with a textbox named Searchbox and a search button that searches by ID.I have one more unbound form called frmDisplay that displays the search result in it which I would like to edit when necessary. The textbox fields for this form are EID, Fname, Lname.
The problem I am having is when I enter the ID# in the searchbox and click the search button (where I linked both ID fields in the button wizard) it keeps on displaying the second record in my table. This is the code I currently have running
Private Sub Form_Load()
Dim rst As Recordset
Set rst = CurrentDb.OpenRecordset("SELECT * from tblEmployees WHERE ID=ID")
EID.Value = rst!ID
Fname.Value = rst!First
Lname.Value = rst!Last
end sub
When I change the code to read
("SELECT * tblEmployees WHERE ID=" & ID")
I get a syntax error missing operator in query expression ID="
ID must have some value. Then concatenate ID:
"Select * From tblEmployees Where ID = " & ID & ""
The recordset that's currently being opened will include all the records in your table, because for every record the condition ID = ID will always be true. It's purely coincidence that it's displaying the second record from your table. You didn't specify a sort on the recordset query so it could randomly pick up any record as the first one in the results. What you actually need is
Set rst = CurrentDb.OpenRecordset("SELECT * from tblEmployees WHERE ID = " & frmSearch!Searchbox)

Sort Contacts into Smart Group if Company Box is Checked

I found an Applescript at apple's support site to sort any contact with the "Company" checkmark checked into a "Business" group:
property groupName : "Business"
tell application "Contacts"
if (name of groups as list) does not contain groupName then
make new group at end of groups with properties {name:groupName}
end if
repeat with singlePerson in people
if company of singlePerson is true then
if (people of group groupName as list) does not contain (singlePerson as list) then
make new person at end of group groupName with data singlePerson
end if
end if
end repeat
save
end tell
It fails on:
make new person at end of group groupName with data singlePerson
With error:
error "Contacts got an error: AppleEvent handler failed." number -10000
Does anyone know of a method to sort out all contacts checkmarked as "Company"?
For example I do NOT want anyone who has a company name but is an individual card:
But I DO want companies with the Company box checkmarked:
Note: I was directed to SO for a programmatic answer from Ask Different where I posted this question.
Use the duplicate command to copy a person into a group (doesn't work on smart group)
property groupName : "Business"
tell application "Contacts"
if (name of groups) does not contain groupName then
make new group at end of groups with properties {name:groupName}
end if
with timeout of 600 seconds
set tIDs to id of people of group groupName
repeat with singlePerson in (get people whose its company is true)
if tIDs does not contain id of singlePerson then
duplicate singlePerson to group groupName
end if
end repeat
save
end timeout
end tell

MVC3 validation with data-annotation?

Is it possible to use a data-annotation attribute for dropdownlists to be valid, only if the user selects an option different from one with the value o (zero).
The option with value o (zero) is "Please Select an account", which is selected by default.
I used [Required] attribute to validate this dropdownlist, but it doesn't have any effect, because, how I said, by default the option with value o (zero)- "Please Select an account"- is selected.
Something like:
[Range(1, int.MaxValue, ErrorMessage = "Please enter a value bigger than {1}")]
public int Value { get; set; }
Making a drop-down list required does not make sense. What you want required is that the user pick a value other than zero from the drop-down list. So what should be required is the SelectedAccount property. You should use the MVC helper method to bind the drop-down selected value to the SelectedAccount property:
#Html.DropdownListFor(m => m.SelectedAccount, new SelectList(Model.Accounts))
I am probably off on the syntax but you can look that up.
Now with regards to your other issue of ensuring that the value is not zero. Is the account number represented as a number or can it contain non-numeric characters? If it is a number then you should represent it as such in your code. And if it is truly a string, then the first value of your drop-down list should be an empty string and not zero.
If you decide that it is a number, then use the Range annotation to ensure that the value is greater than zero:
[Required]
[Range(1, Int32.MaxValue)]
public string SelectedAccountNumber {get;set;}
Hope that helps!

Resources