COGNOS 10.2: Auto-Submit only works by running the report out of report studio - reporting

Hello i am facing following problem.
I am have an report with a prompt page that contains three dates prompts. For each of these prompts I have added a JavaScript-Element so that a specific value is always selected. For this i have used following code:
<script type="text/javascript">
var fW = (typeof getFormWarpRequest == "function" ? getFormWarpRequest(): document.forms["formWarpRequest"]);
if(fW)
{
if(fW._oLstChoices1.length >= 1)
{
fW._oLstChoices1.selectedIndex = 18;
}
}
</script>
At the end i have a seperate list-prompt filled with static values, that runs the report automatically:
<script>
var form = getFormWarpRequest();
var list = form._oLstChoicesdummy;
list.selectedIndex = 0;
canSubmitPrompt();
setTimeout('oCVRS.promptAction(\'finish\')', 0);
</script>
When I open the report in Report Studio and click on "RUN", the report is executed automatically. But if I run the report outside of Report Studio, the prompt mask appears again and I have to click on "Finish/Run".
Has anyone faced silimiar problems and knows how to solve it?
Thanks in advance

If anyone else should face the same problem you can use the following code that will autosubmit the prompt page:
<script type="text/javascript">
//get the form request
var fW = (typeof getFormWarpRequest == "function" ? getFormWarpRequest() : document.forms["formWarpRequest"]);
if (fW)
{
// if the report is running from reportStudio or the Portal objects are different
if (fW.elements["cv.id"].value == "RS")
{
setTimeout('oCVRS.promptAction(\'next\')', 1000);
}else{
setTimeout('oCV_NS_.promptAction(\'next\')', 1000);
}
}
</script>

Related

Attempting to make a Timeout for a google script UI alert

I am trying to figure out if I can Auto-Magically select no in a UI alert in google script..
var old = e.oldValue;
var ui = SpreadsheetApp.getUi() ;
if( old == null ){} else{
if( old == "NO"){} else {
if(e.range.getRow() == 3 ) {}
else{ var response = ui.alert('⚠️ Change order? ⚠️', 'Are you sure you want to change this order?',ui.ButtonSet.YES_NO)}}} ;
if(response == ui.Button.NO) {e.range.setValue(old)} ;
this is where I am at, everything works great.... as long as a button is pressed, I am hoping there is a way to Auto press "no" after ~20 seconds.
This is not exactly you want.
Because it doesn't ask for yes or no. It just shows a timeout message. But I think it can be modified as per your requirement.
function showTimeoutAlert(header, message, time){
SpreadsheetApp.getUi().showModelessDialog(
HtmlService.createHtmlOutput(
'<div>'+ message + '</div>' +
'<script> \
var a = document.querySelector("div"); \
a.addEventListener("click",()=>{setTimeout(google.script.host.close,'+ time +')}); \
a.click(); \
</script>'
).setHeight(50),
header
);
}
Use it like:
showTimeoutAlert("No serial number(s) found", "Sr. No(s) 2, 3 not found", 2000)
It will show this message for 2 seconds
One can adjust timeout time in milliseconds.
I believe your goal as follows.
You want to automatically run the script as clicking "NO" button after 20 seconds from opening the dialog.
Modification points:
Unfortunately, in the current stage, the count down cannot be achieved with SpreadsheetApp.getUi().alert(). So in your situation, in order to achieve your goal, I would like to propose to use the custom dialog. When the custom dialog is used, Javascript can be used. By this, the count down can be used.
When above points are reflected to a script, it becomes as follows.
Sample script:
Google Apps Script side:
Please copy and paste the following script to Code.gs of the script editor of Spreadsheet.
function processForNo(value) {
// do something
Browser.msgBox(`Clicked NO. Retrueved value is '${value || ""}'.`);
}
function processForYes(value) {
// do something
Browser.msgBox(`Clicked YES. Retrueved value is '${value || ""}'.`);
}
// Please run this function.
function main() {
var value = "ok";
var html = HtmlService.createTemplateFromFile("index");
html.value = value;
SpreadsheetApp.getUi().showModalDialog(html.evaluate().setHeight(100), '⚠️ Change order? ⚠️');
}
HTML & Javascript:
Please copy and paste the following script to index.html of the script editor of Spreadsheet.
Are you sure you want to change this order?
<input type="button" id="yes" value="YES" onclick="google.script.run.withSuccessHandler(google.script.host.close).processForYes()">
<input type="button" id="no" value="NO" onclick="processForNo('')">
<script>
const processForNo = _ => google.script.run.withSuccessHandler(google.script.host.close).processForNo(<?= value ?>);
setTimeout(processForNo, 20000);
</script>
When main() of above script is run, a dialog is opened. When you don't click the buttons, the dialog is closed after 20 seconds, and the process is run as clicking "NO" button. At that time, processForNo is run. Also, the value can be sent when the dialog is opened.
When "YES" button is clicked, processForYes is run.
Testing:
When above script is tested, the following situation is obtained.
Note:
Above script is a sample script for confirming the script. When above script is included in your script, it becomes as follows.
Google Apps Script side
function myFunction() {
// do something. I cannot understand about your whole script. So please add your actual script and function name.
var old = e.oldValue;
var ui = SpreadsheetApp.getUi();
if (old == null) {
} else {
if (old == "NO") {
} else {
if (e.range.getRow() == 3) {
} else {
var html = HtmlService.createTemplateFromFile("index");
html.value = old;
ui.showModalDialog(html.evaluate().setHeight(100), '⚠️ Change order? ⚠️');
}
}
}
}
function processForNo(old) {
// do something
}
function processForYes(value) {
// do something
}
HTML & Javascript side is the same with above sample script.
Although I cannot confirm your function name from your question, from var old = e.oldValue in your script, I thought that you might be using the OnEdit trigger of the simple trigger. If my understanding is correct, when you use above script, please use the installable OnEdit trigger. By this, when the cell is edited, showModalDialog works. Ref
References:
Custom dialogs
Installable Triggers

SharePoint Accordion not loading properly

I am working on a SharePoint page, utilizing the jslink for the list web part. I have the following code written out:
(function () {
var overrideCurrentContext = {};
overrideCurrentContext.Templates = {};
overrideCurrentContext.Templates.Header = "<div class='ListAccordion'>";
overrideCurrentContext.Templates.Footer = "</div>";
overrideCurrentContext.OnPostRender = OnPostRender;
overrideCurrentContext.Templates.Item = ItemTemplate;
SPClientTemplates.TemplateManager.RegisterTemplateOverrides(overrideCurrentContext);
})();
function ItemTemplate(ctx) {
var Title = ctx.CurrentItem["Title"];
var Body = ctx.CurrentItem["Body"];
return "<h2>" + Title + "</h2><p>" + Body + "</p><br/>";
}
function OnPostRender() {
$('.ListAccordion h2').click(function () {
$(this).next().slideToggle();
}).next().hide();
$('.ListAccordion h2').css({
"background-color": "#0B0B61",
"cursor": "pointer",
"color": "white" ,
"border-radius" : "15px",
"padding-left" : "10px"
});
}
The problem I am having, is that my accordion view will not display until I utilize the manual refresh option, or I wait for the Asynchronous Automatic Refresh both under the AJAX option of the web part properties.
The accordion shows up perfect, until I save, or reload the page, but it works if I utilize the ajax options. Is there anything I can do to make sure the accordion shows right away when the page is first opened?
also I have the file saved in my siteassets and this is the link I am using ~site/SiteAssets/Accordions12.js
Add the following to the header of your script editor but replace the middle parts with what your file/location is
<script src="/_catalogs/masterpage/test1/jquery-1.11.2.min.js" type="text/javascript"></script>

Microsoft Dynamics CRM 2015 – Need to have Subgrid Lookup Filter

Microsoft Dynamics CRM 2015 –
Need to filter the look up on a subgrid
Javascript code I am using:
function SetCustomLookUp() {
debugger;
lookupFieldObject = Xrm.Page.data.entity.attributes.get('account');
if (lookupFieldObject.getValue() != null) {
entityId = lookupFieldObject.getValue()[0].id;
entityName = lookupFieldObject.getValue()[0].entityType;
entityLabel = lookupFieldObject.getValue()[0].name;
}
var filterXML = [
'<filter type="and">',
'<condition attribute="parentcustomerid" value="{54BC1539-C29C-E511-80E9-3863BB2E6258}" operator="eq"/>',
'</filter>'
].join('\n');
var Subgrid = Xrm.Page.getControl("Contacts");
document.getElementById("Contacts").addEventListener("click", function () {
setTimeout(function () {
var gridControl = Xrm.Page.getControl("Contacts");
var me = gridControl.$c_0.$N_4.$Y_3;
me.addPreSearch(function () {
me.addCustomFilter(filterXML);
});
}, 2000);
});
}
Error: "Cannot read property 'addEventListener' of null"
I used this code and erro thet you present, the reason is:
the subgrid is painting at the end of paint all form, and then you must add this even of click when the sub-grid is painting
I write a small code for this:
var objSubGrid = document.getElementById("subgrid_name");
//CRM loads subgrid after form is loaded.. so when we are adding script on form load.. need to wait until sub grid is loaded.
// that's why we are adding a delay..
if (objSubGrid == null) {
setTimeout(functionxxx, 2000);
return;
} else {
Following article contains answer - http://www.magnetismsolutions.com/blog/paulnieuwelaar/2016/06/20/filter-n-n-add-existing-lookup-dynamics-crm-2016-turbo-forms
To Modarators - Yes, I know that it is recommended to retype everything that is mentioned in article but I'm pretty sure that article will be available online for a long time so I just will not retype because it has no sense for me.

Rich Text Editor (WYSIWYG) in CRM 2013

Sometimes it is useful to have the HTML editor in CRM interface. It is possible to implement the editor directly to CRM 2013. As editor we will use ckeditor which allows to use it without installation on the server.
Identify the field where you would like to use the rich text editor.
Create html-webresource which will define ckeditor. Go to Settings-Customizations-Customize the System-Web Resources.
In html editor of web resource, select the Source tab and insert the following code:
<html>
<head>
<title></title>
<script src="//cdn.ckeditor.com/4.4.7/standard/ckeditor.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script type="text/javascript">
function getTextFieldName()
{
var vals = new Array();
if (location.search != "")
{
vals = location.search.substr(1).split("&");
for (var i in vals)
{
vals[i] = vals[i].replace(/\+/g, " ").split("=");
}
//look for the parameter named 'data'
for (var i in vals)
{
if (vals[i][0].toLowerCase() == "data")
{
var datavalue = vals[i][2];
var vals2 = new Array();
var textFieldName = "";
vals2 = decodeURIComponent(datavalue).split("&");
for (var i in vals2)
{
var queryParam = vals2[i].replace(/\+/g, " ").split("=");
if (queryParam[0] != null && queryParam[0].toLowerCase() == "datafieldname")
{
textFieldName = queryParam[1];
}
}
if (textFieldName == "")
{
alert('No "dataFieldName" parameter has been passed to Rich Text Box Editor.');
return null;
}
else
{
return textFieldName;
}
}
else
{
alert('No data parameter has been passed to Rich Text Box Editor.');
}
}
}
else
{
alert('No data parameter has been passed to Rich Text Box Editor.');
}
return null;
}
CKEDITOR.timestamp = null;
​// Maximize the editor window, i.e. it will be stretched to target field
CKEDITOR.on('instanceReady',
function( evt )
{
var editor = evt.editor;
editor.execCommand('maximize');
});
var Xrm;
$(document).ready(function ()
{
​ // Get the target field name from query string
var fieldName = getTextFieldName();
var Xrm = parent.Xrm;
var data = Xrm.Page.getAttribute(fieldName).getValue();
document.getElementById('editor1').value = data;
/*
// Uncomment only if you would like to update original field on lost focus instead of property change in editor
//Update textbox on lost focus
CKEDITOR.instances.editor1.on('blur', function ()
{
var value = CKEDITOR.instances.editor1.getData();
Xrm.Page.getAttribute(fieldName).setValue(value);
});
*/
// Update textbox on change in editor
CKEDITOR.instances.editor1.on('change', function ()
{
var value = CKEDITOR.instances.editor1.getData();
Xrm.Page.getAttribute(fieldName).setValue(value);
});
// Following settings define that the editor allows whole HTML content without removing tags like head, style etc.
CKEDITOR.config.allowedContent = true;
CKEDITOR.config.fullPage = true;
});
</script>
<meta>
</head>
<body style="word-wrap: break-word;">
<textarea class="ckeditor" cols="80" id="editor1" name="editor1" rows="10"></textarea>
</body>
</html>
Note:
As you can see, there are a few important sections
a) The following code loads the ckeditor and jquery from web so that they don't have to be installed on server.
<script src="//cdn.ckeditor.com/4.4.7/standard/ckeditor.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
b) Function getTextFieldName() which gets the name of target field where should be rich text editor placed. This information is obtained from query string. This will allow to use this web resource on multiple forms.
c) Initialization of ckeditor itself - setting the target field and properties of ckeditor. Also binding the editor with predefined textarea on the page.
Open the form designer on the form where you would like to use ​WYSIWYG editor. Create a text field with sufficient length (e.g. 100 000 chars) which will hold the html source code.
Insert the iframe on the form. As a webresource use the resource created in previous steps. Also define Custom Parameter(data) where you should define the name of the text field defined in step 4. In our situation we created new_bodyhtml text field so the parameter holds this value. This value is returned by the getTextFieldName() of the web resource.
Do not forget to save and publish all changes in CRM customization otherwise added webresources and updated form are not available.
That's all, here is example how it looks like:
Yes, you can use CKEditor, but when I implemented the CKEditor on a form, it turns out it is quite limited in the functionality in provides. Also, the HTML it generates leaves much to be desired. So, I tried a similar idea to Pavel's but using a backing field to store the actual HTML using TinyMCE. You can find the code here:
Javascript
HTML
Documentation
I have package my solution as a managed and unmanaged CRM solution that can be imported and utilised on any form. Moreover, it works on both CRM 2013 and CRM 2015

does tapestry 5 support vbscript?

I've been asked to 'sniff' users' windows username via a vbscript snippet and am having trouble getting this to work in the tapestry (5.1.0.5) application.
It seems tapestry is trying to interpret the vbscript as javascript and therefore failing.
The vbscript snippet (below) is embedded within a component which is in turn loaded conditionally inside a zone as part of a multizoneupdate.
pseudo tml:
<page>
<t:zone>
<t:if>
<t:mycomponent>
<vbscript />
vbscript:
<script type="text/vbscript" language="vbscript">
Dim shell
set shell = createobject("wscript.shell")
set env = shell.environment("process")
set field = document.getElementById("windowsLoginField")
if field is nothing then
alert("no field")
else
field.value = env("username")
end if
</script>
I am aware that this should only work for IE, however other browsers should fail gracefully (not run the script).
When the zone is re-loaded in a state where the vbscript should be rendered, I get the following error in firebug:
missing ; before statement
Dim shell
This is because the script is being evaluated by prototypejs:
evalScripts: function() {
return this.extractScripts().map(function(script) { return eval(script) });
},
Does anyone know of a way to avoid prototype evaluating this script so that it can make it through and be executed as vbscript?
I notice there is no #IncludeVbScriptLibrary annotation ...
thanks, p.
Tapestry inherits this problem from prototype. One solution is to patch the prototype extractScripts and evalScripts so that they do what you want when they see vbscript.
This code works (tested in IE7 and Chrome), but it could be made more flexible (keys off of type and not language for instance)
<script type="text/javascript">
String.prototype.extractScripts = function() {
var matchAll = new RegExp(Prototype.ScriptFragment, 'img');
var matchOne = new RegExp(Prototype.ScriptFragment, 'im');
var matchVBScript = new RegExp('<script.*type=(["\'])text\/vbscript\\1');
return (this.match(matchAll) || []).map(function(scriptTag) {
return [matchVBScript.match(scriptTag), (scriptTag.match(matchOne) || ['', ''])[1]];
});
}
String.prototype.evalScripts = function() {
return this.extractScripts().map(function(script) {
// if it's vbscript and we're in IE then exec it.
if ( script[0] && Prototype.Browser.IE ) return execScript(script[1], "VBScript");
// if it's not vbscript then eval it
if ( !script[0] ) return eval(script[1]);
});
}
</script>

Resources