I have a list of email ids.i want to filter inbox messages and display only emails from those users in thunderbird. Please help me doing this.
This is what i tried so far and it's not working.But im getting completely irrelevant error message "We are unable to print or preview this page".
var gLocalIncomingServer = MailServices.accounts.localFoldersServer;
var gLocalMsgAccount = MailServices.accounts.FindAccountForServer(
gLocalIncomingServer);
var gLocalRootFolder = gLocalIncomingServer.rootMsgFolder
.QueryInterface(Ci.nsIMsgLocalMailFolder);
const kInboxFlag = Components.interfaces.nsMsgFolderFlags.Inbox;
var gLocalInboxFolder = gLocalRootFolder.getFolderWithFlags(kInboxFlag);
gLocalRootFolder.findSubFolder(gLocalInboxFolder.URI);
gLocalInboxFolder.setFlag(Ci.nsMsgFolderFlags.Mail);
// Force an initialization of the Inbox folder database.
var folderName = gLocalInboxFolder.prettiestName;
var aValue = "example#domain.com";
var aAttrib = Ci.nsMsgSearchAttrib.Sender;
var aop = nsMsgSearchOp.Contains;;
var hitCount = 1;
var searchListener =
{
onSearchHit: function(dbHdr, folder) { hitCount++; },
onSearchDone: function(status)
{
print("Finished search does " + aHitCount + " equal " + hitCount + "?");
searchSession = null;
do_check_eq(aHitCount, hitCount);
if (onDone)
onDone();
},
onNewSearch: function() {hitCount = 0;}
};
// define and initiate the search session
var hitCount;
var searchSession = Cc["#mozilla.org/messenger/searchSession;1"]
.createInstance(Ci.nsIMsgSearchSession);
searchSession.addScopeTerm(Ci.nsMsgSearchScope.offlineMail, gLocalInboxFolder);
var searchTerm = searchSession.createTerm();
searchTerm.attrib = aAttrib;
var value = searchTerm.value;
// This is tricky - value.attrib must be set before actual values
value.attrib = aAttrib;
value.str = aValue;
searchTerm.value = value;
if (aAttrib > nsMsgSearchAttrib.OtherHeader)
searchTerm.arbitraryHeader = gArrayHdrs[aAttrib - 1 - nsMsgSearchAttrib.OtherHeader];
searchTerm.op = aOp;
searchTerm.booleanAnd = false;
searchSession.appendTerm(searchTerm);
searchSession.registerListener(searchListener);
searchSession.search(null);
alert("search is done:");
Have you seen this Mozilla page? How do I search for a particular contact property (name, email)?
You don't really need to write any JS code to accomplish this. Thunderbird's search mechanism can be used in two UI-accessible ways:
Define a "saved search" folder. This filters one or more folders with a set of criteria and presents the results in a single folder. See and be aware you probably want an offline search since it will be faster than asking the IMAP server: http://kb.mozillazine.org/Saved_Search
Define a "mail view" that can be applied to any folder. Customize the mail toolbar by right clicking on it, choosing "customize..." and dragging the combo-box labeled "Mail Views" to the toolbar. Close the customize dialog by hitting "Done". Click on the combo-box on the toolbar, choose "customize...", hit "new..." to define and name your filter criteria. You can then apply the mail view by clicking on the combo box and locating it under the "Custom Views" header.
For your filter criteria, you can either type in all the names as separate predicates where "any" rule matches, or you might want to use the "is in my address book" predicate and just put all of those people in a special address book. For example, such a rule would look like: "From" "is in my address book" "cool people". You can create a new address book via "File... New... Address Book" from the Address Book window.
If you prefer to do things programatically and you want to be able to have the list of people vary at runtime, you will want to check out my blog post on creating quick filter bar extensions, as that's the easiest way to hook custom filtering logic into the Thunderbird UI that won't break:
http://www.visophyte.org/blog/2010/05/02/thunderbird-quick-filter-bar-extensions-theyre-a-thing/
Code for that example currently lives here on github:
github.com/asutherland/qfb-pivot
If your list of e-mails isn't going to change a lot, you can also create the "saved search folders" (virtual folders, internally), you should check out mxr.mozilla.org/comm-central/source/mailnews/base/src/virtualFolderWrapper.js and its createNewVirtualFolder method.
Apologies for de-hyperlinking two of the URLs, but the anti-spam mechanism won't let me have more than 2 links in the post...
Related
I am an inexperience technical developer working on my first SuiteScript using SuiteScript 1.0. I am getting an SSS_MISSING_REQD_ARGUMENT error, but I am sure there are many more in my code. The purpose of the script is to populate the department field on the expense record line item from a joined record. The end user will select a Project on the expense line, and the script should look up the department on the project record (a custom field) and add the value to the native department field. Code is copied below.
function ProjectSegment ()
{
var record = nlapiLoadRecord(nlapiGetRecordType(), nlapiGetRecordId());
var recordID = nlapiGetRecordId(record);
//internal ID of project record
var project = nlapiGetField ('custcol_nra_expense_project');
//load project record
var precord = nlapiLoadRecord('job', project);
//get department on project record (internal ID)
var pdepartment = precord.GetFieldValue('custentity_nra_dept_project');
//get project name from project record
var projectName = precord.GetFieldText('entityid');
//load existing search
var search = nlapiLoadSearch('job','customsearch161');
//add filter to include project name
search.addFilter(new nlobjSearchFilter('entityid',null,'is',projectName));
//run search
var resultSet = search.runSearch();
//get department line
var departmentResult = new nlobjSearchColumn('custentity_nra_dept_project');
//set value
nlapiSetFieldTexts('job','department',1,departmentResult)
//record.commitLineItem('department');
nlapiSubmitRecord(record, true);
}
//internal ID of project record
var project = nlapiGetFieldValue ('custcol_nra_expense_project');
Praveen Kumar's response is correct regarding the missing required argument, but there are many other issues with the script as you've surmised.
Side notes:
The getFieldValue and getFieldText methods of nlobjRecord are not capitalized.
For performance reasons, you could/should use a search to get the values you need from the job record. Loading a record just to get field values is wasteful unless you mean to change the record.
Your search filter should probably be based on the value (not text) of the entityid in the job record.
Your desired search column probably is invalid (I don't think a custentity field could be on a job record).
Getting the search result is incorrect.
You want something like this instead:
var result = resultSet.getResults(0, 1);
if (result) {
var department = result.getValue('custentity_nra_dept_project');
// etc.
}
All that said, though, from your description, I don't think you need the search anyway. Once you have pdepartment (again, using precord.getFieldValue), I think all you need is:
record.setFieldValue('department', pdepartment);
Or if you're setting the line-level department, it would be different.
What kind of script is this? I'd like to make more recommendations, but it depends on what's going on.
I have a lookup field which shows a lookup for 4 entities. So, I have added the PreSearch Filter to filter only the contacts when I click on the field.
But, when I click on Look for more Records, I want the search to be made only on Contacts entity.
I want to see only Contacts entity on the following image :
Is it possible?
It’s not possible to hide those related entities from the list. But we can disallow the users to choose any other unwanted entity records in that lookup.
We have to use addPreSearch and addCustomFilter. For example, to allow users to choose only contact but not account or systemuser, see the following snippet. This will filter out account & systemuser records from the view & users can move forward only by choosing contact.
var contactFilter = "<filter type='and'><condition attribute='contactid' operator='not-null' /></filter>";
//remove accounts
var accountFilter = "<filter type='and'><condition attribute='accountid' operator='null' /></filter>";
//remove system users
var systemUserFilter = "<filter type='and'><condition attribute='systemuserid' operator='null' /></filter>";
Xrm.Page.getControl('requiredattendees').addCustomFilter(contactFilter, "contact");
Xrm.Page.getControl('requiredattendees').addCustomFilter(accountFilter, "account");
Xrm.Page.getControl('requiredattendees').addCustomFilter(systemUserFilter, "systemuser");
Read more
Edit:
Adding another undocumented (hence unsupported) till 8.x
Xrm.Page.getAttribute('your_field').setLookupTypes(['contact']);
9.x documented & supported way:
Xrm.Page.getControl('your_field').setEntityTypes(['contact']);
Update: (replacement of above deprecated syntax)
function onFormLoad(executionContext) {
var formContext = executionContext.getFormContext();
formContext.getControl('your_field').setEntityTypes(['contact']);
}
Read more
We have an application which has used a local AD to fetch user info. Some customers want to move to the cloud and are using Azure AD. We extended the app to sign users in via owin and now we're fetching users via Microsoft Graph.
However from Microsoft Graph we do not get full user profiles. We want to fetch all properties on users, not just the basic ones.
var client = new RestClient(string.Format("https://graph.microsoft.com/v1.0/users/{0}", userEmail));
request = new RestRequest();
request.Method = Method.GET;
request.AddHeader("Authorization", _token.Token);
var reponse = client.Execute(request);
This only gives me some information though, for example I don't get 'Department' from this.
Is it possible to configure in azure what should be returned here, if so then where? Or do I need something other than /users/?
Different customers might have different special properties that need to be fetched. So the best solution would be to have an endpoint to call and get everything, including special properties not standard in azure ad. After that I can parse it on my side. Is this possible?
The app has permission to read both basic and full profiles. Do I need something more?
That's the normal behaviour of Graph API, see documentation here and this extract:
By default, only a limited set of properties are returned (
businessPhones, displayName, givenName, id, jobTitle, mail,
mobilePhone, officeLocation, preferredLanguage, surname,
userPrincipalName).
To return an alternative property set, you must specify the desired
set of user properties using the OData $select query parameter. For
example, to return displayName, givenName, and postalCode, you would
use the add the following to your query
$select=displayName,givenName,postalCode
You have to specify all fields in the select, as $select=* will only output the key fields in Graph API implementation.
So you will not be able to get what you ask (variable custom fields).
More info on the fields of User can be found here
User user = await graphServiceClient
.Users[emailId]
.Request()
.Select(aadUser => new
{
aadUser.Id,
aadUser.UserPrincipalName,
aadUser.DisplayName,
aadUser.GivenName,
aadUser.Surname,
aadUser.City,
aadUser.MailNickname,
aadUser.UserType
})
.GetAsync()
.ConfigureAwait(false);
As already stated by NicolasR, you must list all the fields you want to retrieve by using the "$select" parameter; if you want, instead, to retrieve the custom fields, you can either add them to the previous parameter (if you know their names) or you can use "$expand=extensions"
function getGraphDataAdvanced($authToken, $urlGraph){
$url = $urlGraph + '&$count=true'
$data = (Invoke-RestMethod -Headers #{
Authorization = "Bearer $($authToken)"
ConsistencyLevel = "eventual"
} -Uri $url -Method Get)
$dataList = #()
$dataList += $data.value
$url = $data.'#Odata.NextLink'
while ($null -ne $url){
Write-Warning 'Retreiving Next Page'
$data = (Invoke-RestMethod -Headers #{
Authorization = "Bearer $($authToken)"
ConsistencyLevel = "eventual"
} -Uri $url -Method Get)
$dataList += $data.value
$url = $data.'#Odata.NextLink'
}
return $dataList
}
getGraphDataAdvanced $authToken 'https://graph.microsoft.com/beta/users? $expand=extensions'
Using the Microsoft Graph Explorer, I've been able to find all available properties for a user:
Go to "Groups"
Select "list all groups in my organization"
Change the query to filter by a group you know and expand members: https://graph.microsoft.com/v1.0/groups?$filter=mail eq 'aGroup#company.com'&$expand=members
Now you'll see all the available properties for the users.
I've been trying to find a way to get all Azure AD properties of objects via Powershell MSGraph cmdlets without it truncating at the right edge of the console.
I've discovered that Format-Custom triggers vomiting of (apparently) all properties of an object in a huge, alphabetical, indented, and bracketed list.
Get-MgUser -filter "startswith(userprincipalname, 'username')" | format-custom
The formatted properties of a newly created and unused user account in Azure AD is 13217 lines long.
This function buttonBuzz() works inside the Forms of the Entities Account, Contacts and Leads. But not in the Opportunity form.
Mainly because there is no telephone1 attribute. There is however a Contact entity added with "Quick View" in a section with a telephonenumber inside.
I think it can be accessed with the telephone1 as well just not with Xrm.page
Any ideas how i can grab the attribute from inside the "quick view"?
I dont know if the "Quick view" window is a form of an iFrame. And if it is i have no clue how to access it with the Xrm.Page.getAttribute("telephone1").getValue();
function buttonBuzz(exObj) {
var phoneNumber;
// Here i store the "telephone1" Attribute from the current .page
phoneNumber = Xrm.Page.getAttribute("telephone1").getValue();
if (phoneNumber != null) { **Sends phonenumber** } ...
Quick Views display data from a record selected in a lookup field, in this case a Contact. You can query data from related records using the OData endpoint.
You first need to get the Guid of the record selected:
var contactId = Xrm.Page.getAttribute("parentcontactid")[0].id || null;
You would then need to send a SDK.REST request, passing parameters for the Id of the record (contactId), entityName and the columns:
var entityName = "Contact";
var columns = "Address1_Telephone1, FirstName, LastName";
SDK.REST.retrieveRecord(contactId, entityName, columns, null, function(result) {
// Success, logic goes here.
var address1_Telephone1 = result.Address1_Telephone1;
}, function(e) {
console.error(e.message);
});
As well as your JavaScript file, you would need to include the SDK.REST.js file that is included in the MS CRM SDK download within your Opportunity form libraries.
You can pull that field up from the Contact into the Opportunity by creating a Calculated Field, setting it equal to parentcontactid.telephone1
Put the field on the form, and you'll be able to .getAttribute() it like any other Opportunity field (being Calculated, it updates itself whenever the source changes).
I am attempting to use the Xrm.Utility.openEntityForm() method to open a new custom entity form and programatically set an entity look up field. I am following an example on http://msdn.microsoft.com/en-us/library/gg334375.aspx very closely but getting nondescript error. Any help with actually setting the field or possibly finding the logs for the error would be appreciated.
The code example I am following.
function OpenNewContact() {
var parameters = {};
//Set the Parent Customer field value to “Contoso”.
parameters["parentcustomerid"] = "2878282E-94D6-E111-9B1D-00155D9D700B";
parameters["parentcustomeridname"] = "Contoso";
parameters["parentcustomeridtype"] = "account";
//Set the Address Type to “Primary”.
parameters["address1_addresstypecode"] = "3";
//Set text in the Description field.
parameters["description"] = "Default values for this record were set programmatically.";
//Set Do not allow E-mails to "Do Not Allow".
parameters["donotemail"] = "1";
// Open the window.
Xrm.Utility.openEntityForm("contact", null, parameters);
}
The function I have created to do the same with my custom entity is as follows :
function createNewService() {
var locationId = trimBrackets(Xrm.Page.data.entity.getId());
var primaryField = Xrm.Page.data.entity.getPrimaryAttributeValue();
var entityLogicalName = Xrm.Page.data.entity.getEntityName();
var parameters = {
cw_location: locationId,
cw_locationname: primaryField,
cw_locationtype: entityLogicalName
};
Xrm.Utility.openEntityForm("cw_service", null, parameters);
}
the name of the entity I am opening a form work = cw_service (this isn't the problem as I can open a blank form with Xrm.Utility.openEntityForm("cw_service");)
the name of the field I am trying to set is cw_location.
I'd post a picture of the error message but I don't have the reputation yet to do that.
For simple lookups you must set the value and the text to display in the lookup. Use the suffix “name” with the name of the attribute to set the value for the text.
Don’t use any other arguments for simple lookups.
For customer and owner lookups you must set the value and the name in the same way you set them for simple lookups. In addition you must use the suffix “type” to specify the type of entity. Allowable values are account, contact, systemuser, and team.
For your example, it is a simple lookup, I suppose. So, Please try using the code below:
var parameters = {
cw_location: locationId,
cw_locationname: primaryField
};
For more information, Please visit Set the value for lookup fields.