IPP Find All Accounts - Best Practice - intuit-partner-platform

I am trying to pull all accounts for a QuickBooks Online account. My user has over 350 accounts to pull. Is there a way to pull them all at once? If not, is there a way to determine how many records there are to pull, then pull them in a group? Here is my code:
//pull a list of all accounts. I can only pull 100 at a time, so I need to keep enumerating until I hit 0
Account acct = new Account();
_accounts = new List<Account>();
for (int i = 1; i < 4; i++)
{
var aList = dataServices.FindAll(acct, i, 100);
if (aList.Count() == 0)
{
break;
}
_accounts.AddRange(aList);
}
I guessed that my clients have no more than 300 accounts. Is there a way I can replace the 3 or use more efficient code?

In QBO, paging is the only option to get all accounts.
In QBD, you can get the count using a rest api.PFB link.
https://developer.intuit.com/docs/0025_intuit_anywhere/0050_data_services/v2/0500_quickbooks_windows/0100_calling_data_services/0015_retrieving_objects#Getting_a_Record_Count

Related

Jira Tempo users are pseudonymised

I am trying to obtain the worklogs using the Jira Tempo REST API.
The server I am working with is an on-premises one.
The data extraction is straightforward with one exception: some users are renamed from john.doe to JIRAUSER12345.
I could not find any rule for this and I also couldn't find any way to map the JIRAUSER12345 to the actual username.
Is there any way of getting the real user name? Is it possible that I am missing some access rights (probably at team level) that forbid me seeing the real user names?
Reading this article gives the reason for the anonymization:
https://tempo-io.atlassian.net/wiki/spaces/KB/pages/1196327022/Why+do+I+see+JIRAUSERxxxx+as+worklog+author
In order to get the correct user id I did something like:
usersCache = {}
def getUserbyKey(key):
if not key in usersCache:
query = {
'key': key
}
response = requests.get(f"{JIRA_BASE_URL}/rest/api/latest/user",auth=authorization, headers=headers, params=query)
j = response.json()
usersCache[key]=j["displayName"]
j = usersCache.get(key)
return j
...
for wl in worklogs:
user = getUserbyKey(wl["worker"])
key = wl["issue"]["key"]
timeSpent = wl["timeSpent"]

send email from currently logged in user when checkbox is TRUE

My question is an extension of this fantastic solution but am hoping to take it one step further. Whenever a user other than me marks the checkbox as TRUE, the sender of the email is always me, since:
Installable triggers always run under the account of the person who created them
Is it possible to capture the user currently logged in and make them the sender, and if so, what am I missing in my code to make that happen?
What I've tried
I believed I had found my answer, but no such luck. This still posts the timestamp to the sheet successfully, but the email sender still shows as me. Any help would be greatly appreciated.
Edit(s):
I noticed in the above solution if (activeUser === effectiveUser) { only "worked" if typed as if (activeUser !== effectiveUser) {. In my attempts at making it work, I made that edit and forgot to revert it.
function sendEmail(e){
var sheet = e.source.getActiveSheet();
var cell = e.range;
var activeUser = Session.getActiveUser().getEmail();
var effectiveUser = Session.getEffectiveUser().getEmail();
if (activeUser !== effectiveUser) {
Logger.log(cell.getColumn());
Logger.log(cell.isChecked());
//Check if the checkbox in column G(index 7) was checked
if(sheet.getName() == "actionItems" && cell.getColumn() == 7 && cell.isChecked()){
//get current row values from column A to column F
var values = sheet.getRange(cell.getRow(),1,1,6).getDisplayValues().flat();
Logger.log(values);
var transmittalNumber = values[0];
var email = values[5];
var query = values[1];
//create and update the email's hmtl body
var templ = HtmlService.createTemplateFromFile('html_template');
templ.query = query;
var message = templ.evaluate().getContent();
//Send email
MailApp.sendEmail({
to: email,
subject: "Oatsies Action Item: "+transmittalNumber,
htmlBody: message
});
//Add timestamp at column H(index 8)
var timeZone = "GMT-7";
var date = Utilities.formatDate(new Date(),timeZone, "yyyy-MM-dd HH:mm");
sheet.getRange(cell.getRow(),8).setValue(date);
}
}
}
From the question
Is it possible to capture the user currently logged in and make them the sender?
If you are using a free Google account (usually gmail.com account) it might be possible if you use the Gmail API and set a way for active users to authorize the access to their Gmail account to send emails. Also it might be possible if you and the user are using a Google Workspace accounts and if you are able to take advantage of company-wide delegation of authority (also might be possible if you are able to configure the user's email addresses as emails aliases of your account).
Regarding the use of Session.getActiveUser().getEmail() it will return the active user email based on a complex rules i.e. your account and active user belongs to the same Google Workspace domains.
Related
Session.getActiveUser().getEmail() results are inconsistent
Domain-wide delegation
getActiveUser() doesn't return the user?

How do I get all ID of the server that has my bot? I need to get all invite links of the server that have my bot

I want to get all the invite links of the guilds/servers that have my bot in, how should I do it?
client.guilds.array().sort() only output server names. How should I get the ID/invite links of the server?
If you want to get the ID's of the servers that have your bot, just loop through the array and print guild.id. For example:
var serverArray = client.guilds.array();
for(i = 0; i < serverArray.length; i++) {
print("Server ID: " + serverArray[i].id);
}
If you want to get an invite link to the server, then use guild.fetchInvites(). Example:
var serverArray = client.guilds.array();
for(i = 0; i < serverArray.length; i++) {
serverArray[i].fetchInvites().then(invites => {
invites.map(invite => {
print("Invite link: " + invite.url);
});
});
}
Note that the above example will only work if there are actually invite links to the server. If there are no invite links, then you can create one using GuildChannel.createInvite(). https://discord.js.org/#/docs/main/11.6.4/class/GuildChannel?scrollTo=createInvite

MSCRM Retrieve Multiple PlugIn limits the other Retrievemultiple uery

In my scenario, there is a plugin (Retrieve Multiple) on Annotation. This plugin is nothing just a part of BLOB Storage solution(used for Attachment Management solution provided by Microsoft). So, it is clear that in our CRM, MicrosoftlLabsAzureBlobstorage is being used.
Now, I am executing a console app which retrieves multiple annotations through Query Expression. When it tries to fetch records around 500 or 600, it throws below error.
{The plug-in execution failed because no Sandbox Hosts are currently
available. Please check that you have a Sandbox server configured and
that it is running.\r\nSystem.ServiceModel.CommunicationException:
Microsoft Dynamics CRM has experienced an error. Reference number for
administrators or support: #AFF51A0F"}
When I fetch specific records or very less records, it executes fine.
So, I my question is that is there any limitation in number for Rerieve Multiple Query ? if retrievemultiple PlugIn exists ?
Is there any other clue that I am not able to find ?
To work around this conflict, in your console application code you may want to try retrieving smaller pages of annotations, say 50 at a time, and loop through the pages to process them all.
This article provides sample code for paging a QueryExpression.
Here's the abridged version of that sample:
// The number of records per page to retrieve.
int queryCount = 3;
// Initialize the page number.
int pageNumber = 1;
// Initialize the number of records.
int recordCount = 0;
// Create the query expression
QueryExpression pagequery = new QueryExpression();
pagequery.EntityName = "account";
pagequery.ColumnSet.AddColumns("name", "emailaddress1");
// Assign the pageinfo properties to the query expression.
pagequery.PageInfo = new PagingInfo();
pagequery.PageInfo.Count = queryCount;
pagequery.PageInfo.PageNumber = pageNumber;
// The current paging cookie. When retrieving the first page,
// pagingCookie should be null.
pagequery.PageInfo.PagingCookie = null;
while (true)
{
// Retrieve the page.
EntityCollection results = _serviceProxy.RetrieveMultiple(pagequery);
if (results.Entities != null)
{
// Retrieve all records from the result set.
foreach (Account acct in results.Entities)
{
Console.WriteLine("{0}.\t{1}\t{2}", ++recordCount, acct.Name,
acct.EMailAddress1);
}
}
// Check for more records, if it returns true.
if (results.MoreRecords)
{
// Increment the page number to retrieve the next page.
pagequery.PageInfo.PageNumber++;
// Set the paging cookie to the paging cookie returned from current results.
pagequery.PageInfo.PagingCookie = results.PagingCookie;
}
else
{
// If no more records are in the result nodes, exit the loop.
break;
}
}
This page has more info and another sample.

Limit of 100 items for graph statuses?

I'm working on a console application to download statuses and such from my own account -- nothing production or public. I'm finding that I can only get the last 100 statuses, but I was hoping to at least go a couple of years back.
I'm using the C# API, with something like:
dynamic response = Client.Get(string.Format("{0}/statuses", Secrets.FacebookUserName));
while (response.data.Count > 0)
{
foreach (dynamic status in response.data)
{
// do stuff
}
response = Client.Get(response.paging.next);
}
This works fine, but stops after 100 records.
I see the same thing when trying to use FQL:
dynamic x = Client.Get("fql", new { q = "select message from status where uid=me() limit 1000" });
Do I need to go down the road of exploring the batch API?