Sitecore ECM op-tin and opt-out roles dates - sitecore

I want to know is there any way to get user subscrition / unsubscrition to email campaign ?
Is it saved in one of databases/tables in MSSQL ?

If you use the approach with opting in and out being determined on the fact if user is in role, then it is stored in the aspnet_UsersInRoles table in your core database. This table does not keep the information when role was assigned to the user. That's why you cannot get information when user subscribed or unsubscribed to email campaign.
The only thing you can check is if user is in the role:
user.IsInRole(roleName)

The user's subscription is driven by the users role, but It is possible to get the users subscriptions in ECM, You just have to use the api.
You can get the contact from the email address:
string fullName = commonDomain + "\\" + Util.AddressToUserName(username);
var contact = Contact.FromName(fullName);
var subscriptions = contact.GetSubscriptions();
Once you have a contact you can call the GetSubscriptions() method which will return the recipient lists the user is signed up to. There are a host of other methods you can call on a contact and if there is a a way to get the date unsubscribed/subscribed it will be here.
If not reflect Sitecore.EmailCampaign.dll and keep looking! There might be some extra information in the automation states table in the Analytics database. More info on automation state here:
https://www.sitecore.net/learn/blogs/technical-blogs/sitecore-magnified/posts/2013/09/ecm-automation-states-magic.aspx
Also noticed there is a method GetUnsubscribersStatistics on the Sitecore.Modules.EmailCampaign.Core.Analytics.AnalyticsHelper class. This will have the date of unsubscription.

Related

NetSuite REST API with Postman: Record not found while using Suiteql

I'm trying to query some records like vendor and customer using suiteql with REST API using Postman.
The issue is that it return everytime the same error:
"Invalid search query. Detailed unprocessed description follows. Search error occurred: Record 'customer' was not found."
I tried:
differents syntax like Customer, CUSTOMER, customers, Customers, CUSTOMERS
but no change.
I added customer access to the role.
Is there something to activate while using suiteql with rest api?
Can you first try with select * from customer and see if any results are returned and then go on appending your conditions like date created greater than this year start
SELECT id, companyname, email, datecreated
FROM customer
WHERE datecreated >= BUILTIN.RELATIVE_RANGES('TFY', 'START')
AND datecreated <= BUILTIN.RELATIVE_RANGES('TFY', 'END');
NetSuite doesn't say it but for a record to be searchable, the user needs to have the following permissions:
Transactions:
Find Transaction
All the records needed
Lists:
Perform search
All the records needed
Setup:
REST WEB Services
Log in using Access Tokens or Oauth 2.0
Reports:
SuiteAnalytics WorkBook

Share Meeting Invite with Service Account and get it from the API

I'm trying to get access to a particular recurring Google Calendar Meeting from a Service Account. The owner of the Calendar Meeting is a real user and created in their personal calendar (which can't be changed at this point). Sharing the entire Google Calendar of that user with the Service Account is not a viable solution.
Instead I've tried to just invite the Service Account to the meeting - so far so good.
However, I'm unable to retrieve that event with the Google Calendar API.
Basically, I'm trying something like this:
scopes = ["https://www.googleapis.com/auth/calendar.readonly"]
google_credentials = ServiceAccountCredentials.from_json_keyfile_name(CREDENTIALS_FILE, scopes)
calendar_service = build("calendar", "v3", credentials=google_credentials)
events_result = calendar_service.events().list(
# calendarId="<some-service-account>#<some-project>.iam.gserviceaccount.com",
calendarId="primary",
singleEvents=True,
).execute()
print(events_result)
events = events_result.get("items", [])
print(events)
Neither getting the calendar with id primary nor with the <some-service-account>#<some-project>.iam.gserviceaccount.com works.
Also getting the calendar list of the service account looks like that:
scopes = ["https://www.googleapis.com/auth/calendar.readonly"]
google_credentials = ServiceAccountCredentials.from_json_keyfile_name(CREDENTIALS_FILE, scopes)
calendar_service = build("calendar", "v3", credentials=google_credentials)
print(calendar_service.calendarList().list().execute())
# OUTPUTS:
# {'kind': 'calendar#calendarList', 'etag': '"<removed>"', 'nextSyncToken': '<removed>', 'items': []}
Thus, an empty items list. I'm not sure what the problem is here - or if that's not even possible.
Am I missing some permissions for the Service Account?

Can't Get 1:m VTiger Relationship to Show on "1" Side

I am trying to implement a 1:m relationship between Contacts & Service Contracts in VTiger 6. We will use the relationship to track Users of our system. Each Contact should only be allowed to be link to 1 Service Contract at a time (1:m).
I was able to get the ServiceContract side of this working by using the following code:
require_once 'vtlib/Vtiger/Module.php';
$scmodule=Vtiger_Module::getInstance('ServiceContracts');
$scmodule->setRelatedList(Vtiger_Module::getInstance('Contacts'), 'Users',Array('SELECT'),'get_related_list');
This added a tab on the right side of Service Contracts titled "Users" with a SELECT button and allows us to ADD/REMOVE Contacts from the list.
However, what we would also like is to have a field on the Contacts page that shows which Service Contract they are linked to.
UPDATE:
I used the following code to add a single Service Contract field to Contacts:
`
include_once('vtlib/Vtiger/Module.php');
$module = Vtiger_Module::getInstance('Contacts');
$blockInstance = Vtiger_Block::getInstance('LBL_CONTACT_INFORMATION', $module);
$fieldInstance = new Vtiger_Field();
$fieldInstance->name = 'SelectYourAccount';
$fieldInstance->label = 'Account';
$fieldInstance->uitype = 10;
$fieldInstance->typeofdata = 'V~O';
$blockInstance->addField($fieldInstance);
$fieldInstance->setRelatedModules(Array('ServiceContracts'));`
The above code worked fine and I have an Account field in contact details that I can link to a single Service Contract; however, when I select a Service Contract for a Contact and then go to the Users list on the Service Contract, the Contact isn't listed.
Any help would be greatly appreciated!
What i understand from your Question is that Contact is your "1" module and Service Contract is "M(Multi Record)" module. Which means 1 Contact will have multiple Service Contract. So in vtiger Service Contract Related List is already given under Contact Module.Please check this image below.
Next in Service Contract you will have Option to select Contact so that Contract will be liked with "1" Contact. See Screenshot here.
I Hope you will get clear picture after reading this of Relation in Vtiger.

Odoo website, Creating a signup page for external users

How can I create a signup page in odoo website. The auth_signup module seems to do the job (according to their description). I don't know how to utilize it.
In the signup page there shouldn't be database selector
Where should I store the user data(including password); res.users or res.partner
you can turn off db listing w/ some params in in odoo.cfg conf
db_name = mydb
list_db = False
dbfilter = mydb
auth_signup takes care of the registration, you don't need to do anything. A res.user will be created as well as a partner related to it.
The pwd is stored in the user.
User Signup is a standard feature provided by Odoo, and it seems that you already found it.
The database selector shows because you have several PostgresSSQL databases.
The easiest way is to set a filter that limits it to the one you want:
start the server with the option --dbfilter=^MYDB$, where MYDBis the database name.
User data is stored both in res.userand res.partner: the user specific data, such as login and password, are stored in res.user. Other data, such as the Name is stored in a related res.partner record.

Accessing Current Recipient in Sitecore 8 Email Experience Manager

How do you get the raw contact id from the ec_contact_id on the URL created by EXM?
We are using Sitecore's EXM to send emails containing links for surveys to recipients. When the recipient takes the survey we want to tie the response back to the recipient. Since EXM puts a unique Id, ec_contact_id, for the contact (encrypted) we want to use that to determine the recipient versus adding our own custom id.
We found this article, https://briancaos.wordpress.com/2015/04/27/sitecore-8-exm-get-the-email-recipient-from-a-sublayout/, and tried implementing it in the Sitecore controller that gets called when the recipient clicks on the link but the resulting recipient name comes back as empty. We don't have a "sc_item_id" value so we tried "_id" and "ec_message_id" in its place but neither value produced a valid contact Id or recipient name. We also tried looking in MongoDB with the decrypted contactId but couldn't find a match.
You could try somthing like this:
//get value of the ec_contact_id parameter for current request
string queryString = WebUtil.GetQueryString( Sitecore.Modules.EmailCampaign.GlobalSettings.AnalyticsContactIdQueryKey);
var shortID = ShortID.TryParse(queryString, out shortID);
System.Guid contactId;
// where initializationVector is System.Guid of your email message item.
using (var cryptoServiceProvider = new GuidCryptoServiceProvider(System.Text.Encoding.UTF8.GetBytes(GlobalSettings.PrivateKey), initializationVector.ToByteArray()))
{
contactId = cryptoServiceProvider.Decrypt(shortID.Guid);
}
When you create a new user in an email list, Sitecore creates a record in the xDB Mongo database. You should be able to get the email address from the users profile.
Tracker.Current.Contact.GetFacet<IContactEmailAddresses>("Emails").Entries[Tracker.Current.Contact.GetFacet<IContactEmailAddresses>("Emails").Preferred]
Tracker.Current.Contact.GetFacet<IContactEmailAddresses>("Emails").Entries["work_email"]