SPFieldUserValue and SharePoint Metadata - metadata

I am using SPFieldUserValue to fetch the users from sharepoint list which is having person column. But my metadata service is facing some problem and it is showing error in navigation of my sharepoint site as -
"The Managed Metadata Service or Connection is currently not
available. The Application Pool or Managed Metadata Web Service may
not have been started. Please Contact your Administrator."
Does this have any connection to SPFieldUserValue function of sharepoint?
When i use this function i get the error as -
Value does not fall within the expected range

I just came across the problem which was causing the exception of value does not fall within the expected range.
I was trying to get list data and putting it into datatable and on datatable i was trying to fetch the user from sharepoint site.
Instead of datatable if i directly get data from sharepoint list, thn there is no exception.
Error Due to
DataTable dtrqacaml = RQA2list.GetItems(oRQA2Query).GetDataTable();
DataView dtview = new DataView(dtrqacaml);
DataTable dtdistinct = dtview.ToTable(true, "RQA_Manager2");
foreach(DataRow dr in dtdistinct.Rows)
{
SPFieldUserValue userValue = new SPFieldUserValue(SPContext.Current.Web, dr["RQA_Manager2"].ToString());
.
.
}
Error Resolution
foreach (SPListItem li in CClist.Items)
{
SPFieldUserValue userValue = new SPFieldUserValue(SPContext.Current.Web, li["CC_Person"].ToString());
.
.
}

Related

delete phone number using ews

I want to manage mailbox contacts in Exchange online using EWS 2.2 in PowerShell. I am able to create, delete and modify (most of the properties)
But I can not set any PhoneNumber (BusinessPhone, MobilePhone, HomePhone) to an empty value. Tried $updateItem.PhoneNumbers[[Microsoft.Exchange.WebServices.Data.PhoneNumberKey]::BusinessPhone] = $null;
and a lot of variations. Always get: "An object within a change description must contain one and only one property to modify."
I saw this post and using the code from there does not create any error message, but the phone number also isn't empty: EWS Delete PhoneNumber Entry on Contact
Any ideas how to set these field empty?

Unable to load accounts with Google Analytics Api

I'm having issues trying to retrive accounts list with google analytics API.
I'm connecting without problems with Oauth2 granting right permission to my App.
$client = new Google_Client();
$client->setAccessType("offline");
$client->setIncludeGrantedScopes(true);
$client->setAuthConfig('path/to/credentials.json');
$client->addScope(array(Google_Service_Analytics::ANALYTICS));
$client->setRedirectUri(getRedirectUri());
...
I'm also able to do some queries with code like the following:
$service = new Google_Service_AnalyticsReporting($client);
$dateRange = new Google_Service_AnalyticsReporting_DateRange();
$dateRange->setStartDate("2019-01-01");
$dateRange->setEndDate("2019-06-30");
// Create the Metrics objects.
$sessions = new Google_Service_AnalyticsReporting_Metric();
$sessions->setExpression("ga:sessions");
$sessions->setAlias("ga:sessions");
...
When I try to retrive accounts list I receive an error 500
$analytics = new Google_Service_Analytics($client);
$accounts = $analytics->management_accounts->listManagementAccounts();
$items = $accounts->getItems();
print_r($accounts);
If I do instead
$analytics = new Google_Service_Analytics($client);
var_dump($analytics->management_accounts);
I'm able to see a json output where no listManagementAccounts is viewable and no account id is available.
Any suggestion on what I'm doing wrong?
I sorted it out deleting and creating again API credentials in Google Console.
Code was fine.

Service Account for google sheets returns not found

I am trying to read a spreadsheet using a service account (I cannot use OAuth, which works, since the process will be running on a server to periodically check sheet data)
I tried several approaches. If I follow the example using oauth I can see the sheet values. However, I need the run the script without any GUI on the background.
I have found this tutorial https://github.com/juampynr/google-spreadsheet-reader
I have created a projec, service account, added viewer role, shared the spreadsheet with the service account email. Generated the key.
It seems that the test program can connect to the google services but the moment it request the spreadsheet the end result is "404 not found".
require 'vendor/autoload.php';
$service_account_file = '/secrets/readsheetmar2019-08b737d1c1cb._portfolio_test.json';
$spreadsheet_id = '1TAWybckPrnWlQxBZh0ScDsFOvftwi2dvTBNGarSdY30';
$spreadsheet_range = '';
putenv('GOOGLE_APPLICATION_CREDENTIALS=' . $service_account_file);
$client = new Google_Client();
$client->useApplicationDefaultCredentials();
$client->addScope(Google_Service_Sheets::SPREADSHEETS_READONLY);
$client->fetchAccessTokenWithAssertion();
$service = new Google_Service_Sheets($client);
//added by me
if ($client->isAccessTokenExpired()) {
print "expired\n";
}else{
print "not expired\n";
}
$result = $service->spreadsheets_values->get($spreadsheet_id, $spreadsheet_range);
var_dump($result->getValues());
Error:PHP Fatal error: Uncaught exception 'Google_Service_Exception' with message '
Error 404 (Not Found)!!1
When the access token retrieved by OAuth2 is used, the Spreadsheet of $spreadsheet_id = '1TAWybckPrnWlQxBZh0ScDsFOvftwi2dvTBNGarSdY30'; can retrieve the values.
When the access token retrieved by Service Account is used, Error 404 (Not Found)!!1 is returned.
If my understanding is correct, please confirm the following points.
Confirmation points:
As a test run, please set the range $spreadsheet_range = '';.
For example, it's $spreadsheet_range = 'Sheet1'.
If the error message of The caller does not have permission is returned, please confirm as follows.
Whether the Spreadsheet of 1TAWybckPrnWlQxBZh0ScDsFOvftwi2dvTBNGarSdY30 is sharing the email of Service Account.
If you didn't share the Service Account to the Spreadsheet, please share the email of client_email in the file of readsheetmar2019-08b737d1c1cb._portfolio_test.json to the Spreadsheet you want to access.
If the error message of Google Sheets API has not been used in project ### before or it is disabled. is returned, please enable Sheets API.
If this was not the solution for your issue, I apologize.

Workday: Put_Customer returning an error

We are using Snaplogic to load records into workday. Currently, extracting customer records from the source and trying to load them into workday using the object Put_Customer of web service Revenue_Management.
I was getting the following error:
But I'm not getting any category information from the source. So, I tried putting the value for Customer_Category_Reference as 1. But I ended up getting the following error.
The documentation for workday is not helpful and this has been a blocker for me for some time now.
Any help will be appreciated.
Update:
Trying to get customer categories using the Get_Customer_Categories object of Revenue_Management web service using Snaplogic. But getting the following error:
Failure: Soap fault, Reason: Processing error occurred. The task submitted is not authorized., Resolution: Address SOAP fault message and retry
Unfortunately I don't have access to a tenant at this time to validate . However it is likely to work based in prior experience . Perhaps you could create a customer in Workday, through the GUI. Then do get customer API call. Note the category reference . Then, use that in your put customer call
If you look at the API documentation, you will find that Put_Customer accepts a WID in the Customer_WWS_Data object. If you search for "Customer Categories" in Workday, you will likely find the report of the same name. Just select the category that you want your newly loaded customers to default to (click on the magnifying class, then on the ellipsis, Integration Ids, View Ids). The Workday ID will appear at the top.
I have not used the Revenue Management API, but my code for creating a position reference in the Compensation API is probably very similar to what you need to do for the Customer Category reference:
public static Position_ElementObjectType getPositionReference(string WID) {
return new Position_ElementObjectType {
ID = new Position_ElementObjectIDType[] {
new Position_ElementObjectIDType {
type = "WID",
Value = WID
}
}
};
}

CRM Plugin that Fires on Send Email

I'm trying to create plugin that fires when an email is sent.
At first I tried using SetState and SetStateDynamicEntity to when the status is changed to completed. However the plugin never gets fired when an email is sent.
So I tried using the "Send" message using OnExecute method. Is it possible to retrieve the sent email entity info? I'm stumped in trying to return the Entity. The code below keeps returning "The given key was not present in the dictionary" error message.
I tried using either "Entity" or "EntityReference" but no luck.
I know that the Send message returns the EmailId. Is the only way to return the Entity from this EmailId?
public override void OnExecute(IServiceProvider serviceProvider, IPluginExecutionContext context)
{
var trace = (ITracingService)serviceProvider.GetService(typeof(ITracingService));
if (!context.InputParameters.Contains("EmailId"))
{
return;
}
var emailId = (Guid)context.InputParameters["EmailId"];
Entity emailEntity = (Entity)context.InputParameters["Target"];
So the way you mentioned is the only correct way to get email records. Totaling up:
Retrieve identifier of email from context.
Retrieve email record using crm endpoint.
Following article contains description that is relevant to CRM 4.0 - http://www.patrickverbeeten.com/Blog/2008/01/25/CRM-40-Plug-in-message-input-parameters haven't seen something similar that was done for CRM 2011/2013/2015/2016.