My Instagram Wall stopped working today with an "Invalid Access Token" error.
Changed my code from
var service = InstagramService.CreateFromClientId(ClientId);
to
var service = InstagramService.CreateFromAccessToken(AccessToken)
Now i only get images from my own user and not as before all taget with eg. swag
How to change so i again can search by tag regardless whoever im authenticated with
//var service = InstagramService.CreateFromClientId(ClientId);
var service = InstagramService.CreateFromAccessToken("AccessToken");
var response = service.Tags.GetRecentMedia("swag", 30);
foreach (var media in response.Body.Data) {
....
}
Related
As the title says, i cant seem to understand why im getting this error for an on change event on a model driven app form. i have to be honest, im using code snippits and chatGPT to try and formulate this because i haven't got a clue!! but i think im close š
for context, when i search for the client in a new enquiry for the code is to get the account manager from the clients record in another table and put it in the enquiry form.
var SDKEnquiry = window.Sdk || {}; (function(){ // This function is called when the customer lookup field on the form is changed this.function = onChangeCustomer(executionContext){ // Get the form context var formContext = executionContext.getFormContext();
// Get the value of the customer lookup field on the enquiry form
var customerLookup = formContext.getAttribute("customerlookup_on_enquiry_form").getValue();
// Check if a customer is selected
if(customerLookup){
// Retrieve the customer account record using the WebApi
Xrm.WebApi.retrieveRecord("account",
customerLookup[0].id, "?$select=accountmanagerid_on_customer_record").then(
function success(result) {
// Get the account manager id from the response
var accountManagerId = result.accountmanagerid_on_customer_record;
// Set the account manager id on the enquiry form
formContext.getAttribute("accountmanagerid_on_enquiry_form").setValue(accountManagerId);
},
function (error) {
// Show an error message
alert(error.message);
}
);
}
} }).call(SDKEnquiry);
This is the error im getting from Power Apps when i run the app and try and use the form. posted as image because im getting a spam warning
Error
Edit:
OKay so i think ive fixed the code, im not getting any errors anymore anyway but when i select the client the field does not pupulate?
var SDKEnquiry = {};
(function(){
this.onChangeCustomer = function(executionContext) {
var formContext = executionContext.getFormContext();
var customerLookup = formContext.getAttribute("w3c_clientcompany").getValue();
if (!customerLookup) {
alert("No customer selected.");
return;
}
Xrm.WebApi.retrieveRecord("account",
customerLookup[0].id, "?$select=w3c_AccountManager")
.then(function success(result) {
var accountManagerId = result.w3c_AccountManager;
formContext.getAttribute("w3c_cam").setValue(accountManagerId);
})
.catch(function (error) {
alert(error.message);
});
};
}).call(SDKEnquiry);
I am making the payment using authorize.net weblink "https://test.authorize.net/gateway/transact.dll" on the sharepoint page.
After filling in the information and making the payment it doest not redirect the page on x_relay_url. Instead, it shows the error of "Sorry something went wrong" as below.
I tried to make the payment using sandbox account. it makes the payment transaction however after transaction it does not redirect on URL instead it shows the error.
var fingerprint1;
var amount1 = "95.00";
$(document).ready(function(){
});
function setFormAction(button) {
var theForm = $(button).parents('form:first')[0];
//sandbox
var loginid = "99NSdk8a"
var txnkey = "9s54MPz333NcVUm5"
//Randomize
var sequence = parseInt(1000 * Math.random());
var tstamp = GetSecondsSince1970 ()
//added for student rate--CHANGE THIS TO USE VARIABLES SET AT PAGE LOAD
if (theForm.student.checked) {
amount1 = "0.05";
} else {amount1 = "95.00"}
// set form action
if (theForm.payment_type[0].checked){
//theForm.action = "https://secure.authorize.net/gateway/transact.dll";
theForm.action = "https://test.authorize.net/gateway/transact.dll";
theForm.method="POST"
} else {
theForm.action = "http://trainingcenter.umaryland.edu/SaveRegistrations/save_registrationSuicidePrevention2019.aspx";
}
// set amount and fingerprint
theForm.x_amount.value = amount1;
theForm.x_fp_hash.value = fingerprint1;
theForm.submit();
return (true);
}
Using Slack, and trying to set up an Outgoing Webhook to send an email when a user types in a certain keyword. Slack sends a POST in the following format:
token=XXXXXXXXXXXXXXXXXX
team_id=T0001
team_domain=example
channel_id=C2147483705
channel_name=test
timestamp=1355517523.000005
user_id=U2147483697
user_name=Steve
text=atsk: ticket#; ticket details
trigger_word=atsk:
It sends this POST to a URL that is set up with this Google script:
function autoMail(sendmail) {
var params = sendmail.parameters;
if (params.token == "XXXXXXXXXXXXXXXXXX") {
var textRaw = String(params.text).replace(/^\s*atsk\s*:*\s*/gi,'');
var text = textRaw.split(/\s*;\s*/g);
var email = "example#gmail.com";
var subject = text[0];
var message = text + "Ticket created by Autoslack Bot";
MailApp.sendEmail(email, subject, message);
} else {
return;
}
}
Which is published as a Web App and set to run as 'Anyone, even anonymous' and been granted permission to use my Google Email.
So if someone types 'atsk: T12345678; User has an issue.' it should send an email to 'example#gmail.com' with the subject 'T12345678' and the message 'T12345678; User has an issue. Ticket created by Autoslack Bot'
I thought this was set up correctly, but I cannot get an email to send to the specified address. Can someone help, please?
I would suggest to create a test function to check the Apps script part on its own like this :
function testAutoMail() {
var parameters={};
parameters['text']='atsk: T12345678; User has an issue.';
parameters['token']="XXXXXXXXXXXXXXXXXX";
var arg = {};
arg['parameters']=parameters;
autoMail(arg);
}
function autoMail(sendmail) {
var params = sendmail.parameters;
if (params.token == "XXXXXXXXXXXXXXXXXX") {
var textRaw = String(params.text).replace(/^\s*atsk\s*:*\s*/gi,'');
var text = textRaw.split(/\s*;\s*/g);
var email = "example#gmail.com";
var subject = text[0];
var message = text + "Ticket created by Autoslack Bot";
Logger.log('MailApp.sendEmail('+email+', '+subject+', '+message+')');
} else {
return;
}
}
And look at the Logger to see if it works.
Is it possible to programmatically add contacts to the adress book/ people app in Windows 10 like it is possible in Android?
I have a server on which contact information is stored, and I would like to make an app to synchronise my contacts with Windows 10.
I tried several things, but it didn't really work out. This is how far I've come:
Successfully download the contact data.
put the contact data in a Contact object.
This is what I've tried:
contacts.ContactManager.requestStoreAsync().done(function (contactStore) {
contactStore.createContactListAsync("name").done(function (contactList) {
for (i = 0; i < data.length; i++) {
var contact = new contacts.Contact;
//populate Contact item
contactList.saveContactAsync(contact);
}
contactList.saveAsync;
});
});
But I'm getting an acces denied error.
Any help would be appreciated. Thanks in advance!
Firstly, ensure you have added the contacts capability in app manifest.
<Capabilities>
<Capability Name="internetClient" />
<uap:Capability Name="contacts"/>
</Capabilities>
You will also get the access denied error if you had not request the read/write permission to the contact store.
ContactStoreAccessType enumeration
In this case, you can request the āappContactsReadWriteā permission.
But as I tested, there will be some API issues when calling the createContactListAsync method.
The current workaround is adding windows Runtime Component wrapper:
public sealed class ContactManagerWrapper
{
public IAsyncAction AddContactAsync(string userName, string email)
{
return AsyncInfo.Run(async (token) =>
{
var store = await ContactManager.RequestStoreAsync(ContactStoreAccessType.AppContactsReadWrite);
var contactLists = await store.FindContactListsAsync();
var contactList = contactLists.FirstOrDefault();
var contact = new Contact();
contact.Name = userName;
contact.Emails.Add(new ContactEmail() { Address = email, Kind = ContactEmailKind.Personal });
await contactList.SaveContactAsync(contact);
});
}
}
WinJS Project:
document.getElementById('click_me').addEventListener("click", function () {
var mgr = new UWPRuntimeComponent.ContactManagerWrapper();
mgr.addContactAsync('Jeffrey', 'jeffrey.chen#example.com').done(function () {
console.log("add contact successfully");
});
});
Try this
contacts.ContactManager.requestStoreAsync(ContactStoreAccessType.AppContactsReadWrite);
instead of this
contacts.ContactManager.requestStoreAsync()
you open the default store and I think its not accessible by developer.
How can I preserve images in a response to an email activity?
The images in the email show when viewed in CRM - they are added as attachments. When I click the 'respond' button, write a response, and send the response the images are stripped from the email and are not attached to the email.
I have been trying all sorts of things with JScript .
I would rather not have to write anything other than JScript.
This is possible with javascript. I don't know what you tried but this can be done. I.e. catch the send event of your form and create the attachment with Javascript.
Other options are:
You could use a workflow to attach the note of the parent email to
the response. But then you will be forced to save your email wait a
little while (execution of the workflow) and then send the email.
Write plug-in code (but you won't use anything else but Javascript
Javascript to delete attachment:
function deleteAttachments(){
var notesId = {GUID of notes};
var objNotes = new Object();
objNotes.DocumentBody = null;
objNotes.FileName = null;
objNotes.FileSize = null;
objNotes.IsDocument = false;
updateRecord(notesId, objNotes, āAnnotationSetā);
}
function updateRecord(id, entityObject, odataSetName) {
var jsonEntity = window.JSON.stringify(entityObject);
var serverUrl = Xrm.Page.context.getServerUrl();
var ODATA_ENDPOINT = ā/XRMServices/2011/OrganizationData.svcā;
var updateRecordReq = new XMLHttpRequest();
var ODataPath = serverUrl + ODATA_ENDPOINT;
updateRecordReq.open(āPOSTā, ODataPath + ā/ā + odataSetName + ā(guidāā + id + āā)ā, false);
updateRecordReq.setRequestHeader(āAcceptā, āapplication/jsonā);
updateRecordReq.setRequestHeader(āContent-Typeā, āapplication/json; charset=utf-8ā³);
updateRecordReq.setRequestHeader(āX-HTTP-Methodā, āMERGEā);
updateRecordReq.send(jsonEntity);
}
I can access the attachments here: https:{org. URL}/xrmServices/2011/OrganizationData.svc/EmailSet(guid'3848cb4d-673f-e211-b9af-005056bd0001')/email_activity_mime_attachment
guid is the guid of the email.
The image is stored in d:Body as Base64.
Now all I need to do is rewrite img for each inline image with src="data:image/png;base64,theverylongstring...
All inline images will be preserved in the response as Base64.