DisableViewPicker in Dynamics CRM - javascript

our CRM was update to this version:
2021 release wave 1 enabled
Server version: 9.2.21054.00135
Client version: 1.4.2741-2105.4
Organization name: ********
Session ID: ********
Time: 6/22/2021 3:47:19 PM
And after this update 1 script stoped working because it tries to disable view picker.
function setDefaultView(viewId, fiedlId) {
Xrm.Page.getControl(fiedlId).setDefaultView(viewId);
**parent.document.getElementById(fiedlId).attributes.disableviewpicker.value = "1";**
}
I tried this options I found online but it seems none of them are supported
function setDefaultView(viewId, fiedlId) {
Xrm.Page.getControl(fiedlId).setDefaultView(viewId);
var partnerField = Xrm.Page.getControl(fiedlId);
partnerField.SetParameter("disableViewPicker", "1");
}
Also when i try to debug this no longer returns information
Is there a new way to turn on/off the view picker with JS?
I cant find any recent information about this subject.
UPDATE:
What i need is, if that source campaign is selected, to disable view picker in that lookup field.
Thanks in advance
Miguel Vale

Related

f7DatePicker selecting previous day depending on timezone

I've uploaded my R Shiny app (using shinyMobile package) to Google Cloud Run using a Dockerfile, and am finding that the date returned by f7DatePicker doesn't match the value on the widget itself. So if I put in 2021-08-02, the actual date it returns (looking at the 'input$x' value) is 2021-08-01, even though the date displayed on the widget is 2021-08-02.
HOWEVER, it appears that this only occurs for users in particular timezones. I'm currently in New Zealand, and am finding that this issue is occurring for the mobile app for NZ based users; however, when I try running the app on a server in the US (i.e. via Browserstack), the date is correctly returned. BUT when I run the app locally on my desktop (in New Zealand), I don't have this issue. So I'm not sure if the issue is at the server end or at the client end.
It's possible that the issue is caused by daylight savings - see this link - but my local server runs fine, so if this were the case, it would have to be the interaction between Cloud Run and mobile somehow.
Here's the code I'm using to calculate client_time and time_zone_offset (based on this link:)
Javascript:
HTML('<input type="text" id="client_time" name="client_time" style="display: none;"> '),
HTML('<input type="text" id="client_time_zone_offset" name="client_time_zone_offset" style="display: none;"> '),
tags$script('
$(function() {
var time_now = new Date()
$("input#client_time").val(time_now.getTime())
$("input#client_time_zone_offset").val(time_now.getTimezoneOffset())
});')
Shiny: (in server.r)
client_time <<- as.numeric(input$client_time) / 1000 # in s
time_zone_offset <<- as.numeric(input$client_time_zone_offset) * 60 # s from GMT
curr_datetime <<- as_datetime(client_time - time_zone_offset)
Any ideas what the issue could be?
Thanks a lot

Error when running Youtube Data Service in App Scripts (js) – Daily Limit for Unauthenticated Use Exceeded

I'm running a custom function in App Scripts which utilizes the Youtube (YouTube Data API v3) advanced service. When running, I get the following error:
GoogleJsonResponseException: API call to youtube.videos.list failed with error: Daily Limit for Unauthenticated Use Exceeded. Continued use requires signup. (line 15).
I'm not sure how to authenticate my application. I've added it to a cloud project and enabled the API's.
Update: Here's what my code looks like:
function getYoutubeData(youtubeId) {
// Don't run on empty
if(!youtubeId){return null}
// Make the request
var vidData = YouTube.Videos.list("statistics, snippet", {id: youtubeId}).items;
if (!vidData|vidData.length<1){return null}
// Get the first item
vidData = vidData[0];
return vidData.statistics
}
I believe your goal as follows.
You want to put the value of vidData.statistics in your script to the cell.
You want to achieve this using custom function like =getYoutubeData(youtubeId).
For this, how about this answer?
Issue and workaround:
Unfortunately, when YouTube Data API of Advanced Google services is used in the custom function, the access token is not used. From your script, I think that the reason of your issue is this. For example, when the function of const sample = () => ScriptApp.getOAuthToken(); is used as the custom function like =sample(), no value is returned. I think that this is the current specification of Google side because of the security.
In order to achieve your goal under above situation, how about the following workarounds?
Workaround 1:
In this workaround, at first, the youtube ID is set to the cells in Google Spreadsheet. And the value of vidData.statistics are retrieved by the Google Apps Script which is not the custom function and replace the youtube ID with the result values.
Sample script:
Please set the range of cells of youtube IDs to sourceRange and the sheet name. At the sample, it supposes that the youtube IDs are put to the cells "A1:A10". And please run getYoutubeData() at the script editor. Of course, you can also set this to the custom menu.
function getYoutubeData() {
const sourceRange = "A1:A10"; // Please set the range of cells of youtube IDs.
const sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Sheet1"); // Please set the sheet name.
const range = sheet.getRange(sourceRange);
const youtubeIds = range.getValues();
const values = youtubeIds.map(([youtubeId]) => {
// This is your script.
if(!youtubeId){return [null]}
var vidData = YouTube.Videos.list("statistics, snippet", {id: youtubeId}).items;
if (!vidData|vidData.length<1){return [null]}
vidData = vidData[0];
return [JSON.stringify(vidData.statistics)];
});
range.setValues(values);
}
Workaround 2:
In this workaround, the custom function is used. But, in this case, the Web Apps is used as the wrapper. By this, the authorization process is done at the Web Apps. So the custom function can be run without the authorization. Please do the following flow.
1. Prepare script.
When your script is used, it becomes as follows. Please copy and paste the following script to the script editor.
Sample script:
// This is your script.
function getYoutubeData_forWebApps(youtubeId) {
// Don't run on empty
if(!youtubeId){return null}
// Make the request
var vidData = YouTube.Videos.list("statistics, snippet", {id: youtubeId}).items;
if (!vidData|vidData.length<1){return null}
// Get the first item
vidData = vidData[0];
return vidData.statistics
}
// Web Apps using as the wrapper.
function doGet(e) {
const res = getYoutubeData_forWebApps(e.parameter.youtubeId)
return ContentService.createTextOutput(JSON.stringify(res));
}
// This is used as the custom function.
function getYoutubeData(youtubeId) {
const url = "https://script.google.com/macros/s/###/exec?youtubeId=" + youtubeId; // Please set the URL of Web Apps after you set the Web Apps.
return UrlFetchApp.fetch(url).getContentText();
}
2. Deploy Web Apps.
On the script editor, Open a dialog box by "Publish" -> "Deploy as web app".
Select "Me" for "Execute the app as:".
By this, the script is run as the owner.
Select "Anyone, even anonymous" for "Who has access to the app:".
In this case, no access token is required to be request. I think that I recommend this setting for testing this workaround.
Of course, you can also use the access token. But, in this case, when the access token is used, this sample script cannot be directly used as the custom function.
Click "Deploy" button as new "Project version".
Automatically open a dialog box of "Authorization required".
Click "Review Permissions".
Select own account.
Click "Advanced" at "This app isn't verified".
Click "Go to ### project name ###(unsafe)"
Click "Allow" button.
Click "OK".
Copy the URL of Web Apps. It's like https://script.google.com/macros/s/###/exec.
When you modified the Google Apps Script, please redeploy as new version. By this, the modified script is reflected to Web Apps. Please be careful this.
Please set the URL of https://script.google.com/macros/s/###/exec to url of above script. And please redeploy Web Apps. By this, the latest script is reflected to the Web Apps. So please be careful this.
4. Test this workaround.
Please put =getYoutubeData("###youtubeId###") to a cell. By this, the youtube ID is sent to the Web Apps and the Web Apps returns the values of vidData.statistics.
Note:
These are the simple sample scripts for explaining the workarounds. So when you use this, please modify it for your actual situation.
References:
Custom Functions in Google Sheets
Web Apps
Taking advantage of Web Apps with Google Apps Script

Office js/Scriptlab - excel beta api data validation list fails with "api not found" error, but excel version is correct

I am trying to create a basic dropdown in excel using Office js beta api.
https://appsforoffice.microsoft.com/lib/beta/hosted/office.js
I am using the example provided in the below documentation for "List validation rule type"
https://learn.microsoft.com/en-us/office/dev/add-ins/excel/excel-add-ins-data-validation
The below code adds data validation rule of type "list" to a range "B2:B5" in the current active sheet:
Excel.run(function (context) {
var sheet = context.workbook.worksheets.getActiveWorksheet();
var range = sheet.getRange("B2:B5");
var nameSourceRange = "Entry1, Entry2, Entry3"
range.dataValidation.rule = {
list: {
inCellDropDown: true,
source: nameSourceRange
}
};
return context.sync();
})
I have imported the "beta" api but the data validation rule fails with the below error. The "Script Lab" official example of "Data Validation" also fails with the same error. Non-beta functionalities are working fine for me and there is no issue with download of the script files from cdn.
"ApiNotFound: The API you are trying to use could not be found. It may be available in a newer version of Excel."
Debug info:
code
"ApiNotFound"
errorLocation
"Range.dataValidation"
message
"The API you are trying to use could not be found. It may be available in a newer version of Excel."
Stacktrace from scriptlab:
Error: The API you are trying to use could not be found. It may be available in a newer version of Excel.
at r (https://appsforoffice.microsoft.com/lib/beta/hosted/excel-win32-16.01.js:21:239022) [<root>]
at i.prototype.processRequestExecutorResponseMessage (https://appsforoffice.microsoft.com/lib/beta/hosted/excel-win32-16.01.js:21:221647) [<root>]
at Anonymous function (https://appsforoffice.microsoft.com/lib/beta/hosted/excel-win32-16.01.js:21:219868) [<root>]
at Zone.prototype.run (https://script-lab.azureedge.net/bundles/polyfills.e10fc062eb880ff38340.bundle.js:1:80212) [<root> => <root>]
at Anonymous function (https://script-lab.azureedge.net/bundles/polyfills.e10fc062eb880ff38340.bundle.js:1:77429) [<root>]
at Zone.prototype.runTask (https://script-lab.azureedge.net/bundles/polyfills.e10fc062eb880ff38340.bundle.js:1:80903) [<root> => <root>]
at drainMicroTaskQueue (https://script-lab.azureedge.net/bundles/polyfills.e10fc062eb880ff38340.bundle.js:1:75624) [<root>]
My excel version is 1708 (Build 8431.2242) which is greater than the minimum specified version of Version 1704 (Build 8201.2001) or later for the beta api to run:
https://dev.office.com/reference/add-ins/requirement-sets/excel-api-requirement-sets

How to access call logs in android using Cordova?

I want to access recent call logs using Cordova but there is no official plugin for that, some guy made a custom plugin for that https://github.com/dalyc/Cordova-CallLog-Plugin is the only hope for me, but the problem is this plugin is no longer supported by its creator and it is using AngularJS in his example. I did my search work and found that People tried to use this plugin to use with javascript but they got no working solution. As the author mentioned here https://github.com/dalyc/Cordova-CallLog-Plugin/issues/4 there are 3 functions that will work with javascript.
window.plugins.calllog.list : get recent calls - takes a day limit e.g 7 is go back a week
window.plugins.calllog.show : show contact for specified phone number
window.plugins.calllog.contact : get contact details for specified phone number
I tried each of them and apparently window.plugins.calllog.show is working fine and it is showing contact for specific numbers. But window.plugins.calllog.list did not worked for me it is returning "undefined". Need help please. Thanks in advance.
my index.html contains
<button id="call_log" onclick="loadLogs();">call log</button>
my app.js contains
//calllog
function loadLogs() {
if(window.plugins.calllog == "undefined"){
alert("Doesn't works");
}
else
{
alert("works");
window.plugins.calllog.show('12345');
//this code is working and opening list of contacts having these "12345" in their phonenumber
var list = window.plugins.calllog.list('7');
alert(list[0]);
}
}
Uncaught TypeError: Cannot read property '0' of undefined
Here is a plugin I have made
https://www.npmjs.com/package/callsplugin
you basically have to write the command
cordova plugin add callsplugin
and follow the instruction you find in the project site

Google App Script suddenly not working in Spreadsheet Form that was formerly working. Fonts Not Found

Google app script is not working with error msg:
"Error encountered: An unexpected error occurred" error console show
that fonts Not Found
"https/fonts.gstatic.com/fonts/css?kit=OtfYXvDq3H9yumjkQUKHI8eAddqfMek1TFqPTmdvyDSVdo-ucNhB"
The error msg states:
fonts Not Found
The app has a form which writes to the Google spreadsheet. As such no font styles are applied, but the form elements may be using some styles internally. The script was working fine last week and the issue came to our notice today. As such no info is found re this issue on the Google app script docs. Can you please advise what is the issue here and how do I get it back to working again.
function doGet() {
var app = UiApp.createApplication().setTitle('Marketing Spends');
createForm_(app);
return app;
}
function createForm_(app){
var grid = app.createGrid(9, 5);
var weekNumber = app.createListBox().setId('weekNumber').setName('weekNumber');
var current_week = Utilities.formatDate(new Date(), 'AEST', 'w');
var currentWeek = app.createLabel('Current week: ' + current_week);
....... The createForm_ function adds all the required form elements(textbox, list, submit button) to the app.
As you stated in your comment, the UI App is now deprecated.
Google Documentation - UI App Deprecated
You must replace all of that code with the HTML Service.

Categories

Resources