Catch response from Windows.UI.Notifications.ToastNotificationManager]::CreateToastNotifier - windows

I create such a notification with an input field
[xml]$ToastTemplate = #"
<toast launch="chatLaunchArg">
<visual>
<binding template="ToastGeneric">
<text>Emily</text>
<text>Coming tonight for the tea party?</text>
</binding>
</visual>
<actions>
<input id="idTextBox1" type="text" placeHolderContent="reply" />
<action content="Send" hint-inputId="idTextBox1" activationType="background" arguments="argSendPress" />
</actions>
</toast>
"#
#Load the ToastTemplate into the required format
$ToastXml = New-Object Windows.Data.Xml.Dom.XmlDocument
$ToastXml.LoadXml($ToastTemplate.OuterXml)
#Display the toast notification
$AppID = '{1AC14E77-02E7-4E5D-B744-2EB1AE5198B7}\WindowsPowerShell\v1.0\powershell.exe'
$Notification = [Windows.UI.Notifications.ToastNotificationManager]::CreateToastNotifier($AppID)
$Notification.Show($ToastXml)
How do I catch user input in the notification window?

Related

REST URL customization

I had to change in the restclient after like this:
var parentresource = '';
switch (resource) {
case 'details':
parentresource = `products/${params.id}/${resource}`;
break;
default:
parentresource = `${resource}`;
}**
url = `${apiUrl}/${**parentresource**}?${fetchUtils.queryParameters(query)}`;
break;
I have a EditView where in one tab I have got:
<ReferenceManyField addLabel={false} reference="details" target="id">
<Datagrid>
<NumberField source="quantity" label="Quantity" />
<TextField source="measurementUnit" label="Measurement" />
<NumberField source="purchasePrice" label="Purchase Price" />
<NumberField source="salesPrice" label="Sales Price" />
<NumberField source="discountPercent" label="Discount Percent" />
<NumberField source="salesTaxPercent" label="Sales Tax Percent" />
<TextField source="supplier" label="Supplier" />
<DateField source="createdDate" label="Created Date" />
<TextField source="status" label="Status" />
<EditButton basePath="/products" />
</Datagrid>
</ReferenceManyField>
When I click EditButton the url in the browser needs to needs to be http://localhost:5000/#/details/1?_k=5f7qc1 but the url to grab data from should be http://localhost:5000/api/products/2/details/1
Any easier way to do this?
That's the job of a custom restclient

JSP kendo grid EDIT /ADD Handle ERROR response from spring rest Kendo UI v2015.3.1111

Trying Kendo UI JSP editable grid. Grid is working with few problems.
(Version : Kendo UI v2015.3.1111 )
Export: Even with allPages="allPages", its exporting only current
page.
After CREATE, GRID is not updated with server response which has user createDate. Same with Update, grid not updated with update date
even though the updated user object is passed.
Grid shows user added even if it failed in the backend. How to handle error response for create /update and show the failed message ?
Any help greatly appreciated.
Controller create part:
#RequestMapping(value = "/user/create", method = RequestMethod.POST)
public #ResponseBody User create(#RequestBody Map<String, Object> model) {
log.debug("create");
User target = new User();
target.setUserName((String)model.get("UserName"));
target.setFirstName((String)model.get("firstName"));
target.setLastName((String)model.get("lastName"));
target.setOpenDate(getDateFromStr((String)model.get("openDate")));
target.setEditDate(getDateFromStr((String)model.get("editDate")));
User user = userDao.createUser(target);
log.info("user"+user.getUserId()+user.getOpenDate());
return user;
}
JSP PART:
<c:url value="/user/create" var="createUrl" />
<c:url value="/user/read" var="readUrl" />
<c:url value="/user/update" var="updateUrl" />
<c:url value="/user/destroy" var="destroyUrl" />
<c:url value="/user/saveexcel" var="saveExcelUrl" />
<c:url value="/user/savepdf" var="savePdfUrl" />
<kendo:grid name="grid" pageable="true" sortable="true" height="750px" filterable="true">
<kendo:grid-scrollable/>
<kendo:grid-pdf fileName="KendoUIGridExport.pdf" allPages="allPages" proxyURL="${savePdfUrl}"/>
<kendo:grid-excel fileName="KendoUIGridExport.xlsx" allPages="allPages" proxyURL="${saveExcelUrl}" />
<kendo:grid-editable mode="popup" confirmation="Are you sure you want to remove this item?"/>
<kendo:grid-toolbar>
<kendo:grid-toolbarItem name="create"/>
<kendo:grid-toolbarItem name="excel"/>
<kendo:grid-toolbarItem name="pdf"/>
</kendo:grid-toolbar>
<kendo:grid-columns>
<kendo:grid-column title="User Name" field="userName" width="120px"/>
<kendo:grid-column title="First Name" field="firstName" width="120px" />
<kendo:grid-column title="Last Name" field="lastName" width="120px" />
<kendo:grid-column title="Open Date" field="openDate" width="120px" format="{0:MM/dd/yyyy}" />
<kendo:grid-column title="Edit Date" field="editDate" width="120px" format="{0:MM/dd/yyyy}" />
<kendo:grid-column title=" " width="150px">
<kendo:grid-column-command>
<kendo:grid-column-commandItem name="edit" />
<kendo:grid-column-commandItem name="destroy" />
</kendo:grid-column-command>
</kendo:grid-column>
</kendo:grid-columns>
<kendo:dataSource pageSize="10" serverPaging="false" serverSorting="false" serverFiltering="false" serverGrouping="false" >
<kendo:dataSource-transport>
<kendo:dataSource-transport-create url="${createUrl}" type="POST" dataType="json" contentType="application/json"/>
<kendo:dataSource-transport-read url="${readUrl}" type="POST" dataType="json" contentType="application/json"/>
<kendo:dataSource-transport-update url="${updateUrl}" type="POST" dataType="json" contentType="application/json" />
<kendo:dataSource-transport-destroy url="${destroyUrl}" type="POST" dataType="json" contentType="application/json" />
<kendo:dataSource-transport-parameterMap>
<script>
function parameterMap(options,type) {
return JSON.stringify(options);
}
</script>
</kendo:dataSource-transport-parameterMap>
</kendo:dataSource-transport>
<kendo:dataSource-schema>
<kendo:dataSource-schema-model id="userId">
<kendo:dataSource-schema-model-fields>
<kendo:dataSource-schema-model-field name="userName" type="string" >
<kendo:dataSource-schema-model-field-validation required="true" />
</kendo:dataSource-schema-model-field>
<kendo:dataSource-schema-model-field name="firstName" type="string">
<kendo:dataSource-schema-model-field-validation required="true" />
</kendo:dataSource-schema-model-field>
<kendo:dataSource-schema-model-field name="lastName" type="string">
<kendo:dataSource-schema-model-field-validation required="true" />
</kendo:dataSource-schema-model-field>
<kendo:dataSource-schema-model-field name="openDate" type="date" editable="false" />
<kendo:dataSource-schema-model-field name="editDate" type="date" editable="false"/>
</kendo:dataSource-schema-model-fields>
</kendo:dataSource-schema-model>
</kendo:dataSource-schema>
</kendo:dataSource>
</kendo:grid>
Resolved myself: For pdf, allPages="true" works.
Grid refresh: FOR requestEnd event
function onRequestEnd(e) {
if (e.type == "create") {
e.sender.read();
}
else if (e.type == "update") {
e.sender.read();
}
}

My form is not repopulated when validation fails

I have a simple page with a firstName field and a lastName field both of which are required. When I only enter one field I get the correct error message but I lose the value I have entered. I do have getters and setters for the fields and the page uses the values correctly if I enter them. Everything seems set up in the same way I had it on my previous project and I did not lose data on those pages. I know this question has been asked before but I can't find anything wrong with my code based on those answers so I am hoping someone can see what I am doing wrong.
My jsp code is:
<s:form action = "sign" validate="true" method="post" id="sign" >
<s:hidden name="dateSigned"></s:hidden>
<div class="row">
<div class = "col-md-7 col-xs-12">
<div class="col-md-3 col-sm-3 col-xs-12"><label for="firstName" class="pull-right"><span class="required">*</span><s:text name="firstName"></s:text>:</label></div>
<div class="col-md-3 col-sm-3 col-xs-12"><s:textfield name = "firstName" id = "firstName" value="" maxlength="50" class="form-control" onchange="dirtyFlag();" tabindex="4"/></div>
<div class="col-md-3 col-sm-3 col-xs-12"><label for="lastName" class="pull-right"><span class="required">*</span><s:text name="lastName"></s:text>:</label></div>
<div class="col-md-3 col-sm-3 col-xs-12"><s:textfield name = "lastName" id = "lastName" value="" maxlength="50" class="form-control" onchange="dirtyFlag();" tabindex="5"/></div>
</div>
</div>
<div class="row">
<s:submit method="save" key="button.save" cssClass="submit" onclick="clearDirtyFlag();" tabindex="1"/>
</div>
My struts action is:
<action name="sign" class="gov.mo.dnr.egims.controller.request.RequestorSignatureAction">
<result name="success" type="tiles">reqSign</result>
<result name="input" type="tiles">reqSign</result>
<result name="error" type="tiles">error</result>
<result name="ownerSignature" type="redirectAction">
<param name="actionName">owner</param>
<param name="namespace">/req</param>
<param name="requestId">${requestId}</param>
</result>
</action>
My tiles code is:
<definition name="reqSign" extends="baseLayout">
<put-attribute name="navbar"
value="/WEB-INF/pages/request/nav_secondary.jsp" />
<put-attribute name="content"
value="/WEB-INF/pages/request/RequestorSignature.jsp" />
</definition>
My struts2 result-types and interceptor code is:
<result-types>
<result-type name="tiles" class="org.apache.struts2.views.tiles.TilesResult" />
</result-types>
<interceptors>
<interceptor name="validUser" class="gov.mo.dnr.egims.controller.interceptors.ValidUser" />
<interceptor-stack name="validUserStack">
<interceptor-ref name="validUser" />
<interceptor-ref name="defaultStack" />
</interceptor-stack>
<interceptor name="userInRole" class="gov.mo.dnr.egims.controller.interceptors.UserInRole">
<param name="rolesList">Administrator,Geologist,Requestor,Reviewer, User</param>
</interceptor>
<interceptor-stack name="userInRoleStack">
<interceptor-ref name="userInRole" />
</interceptor-stack>
</interceptors>
My validation xml is:
<validators>
<field name="firstName">
<field-validator type="requiredstring">
<param name="trim">true</param>
<message key="errors.required" />
</field-validator>
<field-validator type="regex">
<param name="regex">^[ a-zA-Z0-9'\-,.!:##/]*$</param>
<message key="errors.invalidCharacter"/>
</field-validator>
<field-validator type="stringlength">
<param name="maxLength">50</param>
<message key="errors.maxlength"></message>
</field-validator>
</field>
<field name="lastName">
<field-validator type="requiredstring">
<param name="trim">true</param>
<message key="errors.required" />
</field-validator>
<field-validator type="regex">
<param name="regex">^[ a-zA-Z0-9'\-,.!:##/]*$</param>
<message key="errors.invalidCharacter"/>
</field-validator>
<field-validator type="stringlength">
<param name="maxLength">50</param>
<message key="errors.maxlength"></message>
</field-validator>
</field>
Any help would be appreciated, thanks!
Here is the requested dirtyFlag() code (and related code):
//needToConfirm used by confirm exit
var needToConfirm = false;
//default string message to display before leaving a page when data on the page has changed
//these changes were made to allow the message displayed before exiting to be customized
var defaultWarningMessage = "There is unsaved data on this screen. Do you want to exit anyway?";
var dirtyWarningMessage = defaultWarningMessage;
//this line intercepts attempts to leave the page via clicking the X button.
window.onbeforeunload = function ()
{
if (needToConfirm)
{
var outMessage = dirtyWarningMessage;
setDirtyWarningMessage(defaultWarningMessage);
return outMessage;
}
// no changes - return nothing
}
//function to set the string message to display before leaving a page when data on the page has changed
function setDirtyWarningMessage(inMessage)
{
dirtyWarningMessage = inMessage;
}
//function to set dirty flag
function dirtyFlag()
{
//alert ("Dirty flag set");
needToConfirm = true;
}
//function to clear dirty flag
function clearDirtyFlag()
{
//alert ("Dirty flag cleared");
needToConfirm = false;
}
//function to confirm close
function confirmClose()
{
if (needToConfirm)
{
var agree=confirm("Some data on the page is modified. Do you wish to leave the page without saving changes?");
if (agree == true)
{
needToConfirm = false;
window.close();
}
else
{
return false;
}
}
else
{
window.close();
}
}
Guess what ?
<s:textfield name = "firstName"
id = "firstName"
value = ""
maxlength = "50"
class = "form-control"
onchange = "dirtyFlag();"
tabindex = "4"/>
value="" forces the value to always be empty.
Use value="%{firstName}", or
remove it and let name="firstName" do the job (recommended).

Change the "New" button Quote subgrid

The opportunity form as a quotes sub-grid. I am trying to hide the existing "New" button and create a custom one. Hiding the existing button works like a charm. However, nothing I do seems to make the custom button appear.
I have tried making the enable and visibility conditions as simple as just checking that the form is for an existing entity. Nothing seems to work.
Here's the XML for the quote. Generated using Ribbon Workbench:
<RibbonDiffXml xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<CustomActions>
<CustomAction Id="ntcp.quote.Button1.Button.CustomAction" Location="Mscrm.SubGrid.quote.MainTab.Management.Controls._children" Sequence="17">
<CommandUIDefinition>
<Button Alt="$LocLabels:ntcp.quote.Button1.Button.Alt" Command="ntcp.quote.Command0.Command" Description="" Id="ntcp.quote.Button1.Button" Image32by32="/_imgs/ribbon/newrecord32.png" Image16by16="/_imgs/ribbon/New_16.png" LabelText="$LocLabels:ntcp.quote.Button1.Button.LabelText" Sequence="17" TemplateAlias="o1" ToolTipTitle="$LocLabels:ntcp.quote.Button1.Button.ToolTipTitle" ToolTipDescription="$LocLabels:ntcp.quote.Button1.Button.ToolTipDescription" ModernImage="New" />
</CommandUIDefinition>
</CustomAction>
<HideCustomAction HideActionId="ntcp.Mscrm.SubGrid.quote.AddNewStandard.Hide" Location="Mscrm.SubGrid.quote.AddNewStandard" />
</CustomActions>
<Templates>
<RibbonTemplates Id="Mscrm.Templates" />
</Templates>
<CommandDefinitions>
<CommandDefinition Id="ntcp.quote.Command0.Command">
<EnableRules>
<EnableRule Id="ntcp.quote.EnableRule0.EnableRule" />
</EnableRules>
<DisplayRules>
<DisplayRule Id="ntcp.quote.DisplayRule0.DisplayRule" />
</DisplayRules>
<Actions>
<JavaScriptFunction FunctionName="ntcp_QuoteFromOpportunity" Library="$webresource:ntcp_/quoteFromOpportunity.js" />
</Actions>
</CommandDefinition>
</CommandDefinitions>
<RuleDefinitions>
<TabDisplayRules />
<DisplayRules>
<DisplayRule Id="ntcp.quote.DisplayRule0.DisplayRule">
<FormStateRule State="Existing" Default="true" />
</DisplayRule>
</DisplayRules>
<EnableRules>
<EnableRule Id="ntcp.quote.EnableRule0.EnableRule">
<FormStateRule State="Existing" Default="true" />
</EnableRule>
</EnableRules>
</RuleDefinitions>
<LocLabels>
<LocLabel Id="ntcp.quote.Button1.Button.LabelText">
<Titles>
<Title description="Add New Quote" languagecode="1033" />
</Titles>
</LocLabel>
<LocLabel Id="ntcp.quote.Button1.Button.ToolTipTitle">
<Titles>
<Title description="Add New Quote" languagecode="1033" />
</Titles>
</LocLabel>
<LocLabel Id="ntcp.quote.Button1.Button.ToolTipDescription">
<Titles>
<Title description="Add New Quote" languagecode="1033" />
</Titles>
</LocLabel>
<LocLabel Id="ntcp.quote.Button1.Button.Alt">
<Titles>
<Title description="Add New Quote" languagecode="1033" />
</Titles>
</LocLabel>
</LocLabels>
</RibbonDiffXml>
Any ideas?
Is this CRM2011 or CRM2013? If it is CRM2013 you can't add a new button on the Form Subgrids - only on the full related subgrid view.
Buttons are visible by default, so you don't need any special Display/Enable rules.
Hope this helps,
Scott

scriptlla concurrency issues?

I use "antcall" scriptlla concurrent invocations, but appear "javax.mail. Management InstanceNotFoundException".
I set up 10 concurrent, sometimes can be 10, sometimes only a few can rise.
<target name="PAIR_CONN">
<etl debug="true">
<fileset file="Pair_Conn.xml" />
</etl>
</target>
<target name="pair_conn_mult">
<parallel threadCount='5'>
<antcall target="PAIR_CONN">
<param name="g_flag" value="1" />
</antcall>
<antcall target="PAIR_CONN">
<param name="g_flag" value="2" />
</antcall>
<antcall target="PAIR_CONN">
<param name="g_flag" value="3" />
</antcall>
<antcall target="PAIR_CONN">
<param name="g_flag" value="4" />
</antcall>
<antcall target="PAIR_CONN">
<param name="g_flag" value="0" />
</antcall>
</parallel>
</target>
Unable to unregister mbean scriptella:type=etl,url="file:/informatica/infa861/oss_etl_523/src/ElectricCable/Pair_Conn.xml"
javax.management.InstanceNotFoundException: scriptella:type=etl,url="file:/informatica/infa861/oss_etl_523/src/ElectricCable/Pair_Conn.xml"
I view scriptella source code, the code is already synchronized,
public synchronized void register() {
if (name != null) {
throw new IllegalStateException("MBean already registered");
}
server = getMBeanServer();
String url = ctx.getScriptFileURL().toString();
System.out.println("LM:"+url);
boolean registered = false;
for (int i = 0; i < 1000; i++) {
if (name == null || server.isRegistered(name)) {
registered = true;
name = toObjectName(url, i);
System.out.println("LM:"+name);
} else {
registered = false;
break;
}
}
etlThread = Thread.currentThread();
if (!registered) {
try {
server.registerMBean(this, name);
started = new Date();
LOG.info("Registered JMX mbean: " + name);
} catch (Exception e) {
throw new SystemException("Unable to register mbean " + name, e);
}
} else {
throw new SystemException("Unable to register mbean for url " + url + ": too many equal tasks already registered");
}
}
What suggestions to you have for this situation ? What should I try, or what should I read in order to find a solution ?
Thanks for pointing out a serious bug. I've opened JavaForge ticket to track this issue.
As a workaround you can switch to <java fork="true"> task to run Scriptella in a forked VM, so the Ant script will become something like this:
<path id="scriptella.class.path">
<pathelement location="../../build/scriptella.jar"/>
</path>
<taskdef resource="antscriptella.properties" classpathref="scriptella.class.path"/>
<target name="PAIR_CONN">
<java fork="yes" classname="scriptella.tools.launcher.EtlLauncher" classpathref="scriptella.class.path">
<arg value="Pair_Conn.xml"/>
<arg value="-d"/>
<sysproperty key="g_flag" value="${g_flag}"/>
</java>
</target>
<target name="pair_conn_mult">
<parallel threadCount='5'>
<antcall target="PAIR_CONN">
<param name="g_flag" value="1" />
</antcall>
<antcall target="PAIR_CONN">
<param name="g_flag" value="2" />
</antcall>
<antcall target="PAIR_CONN">
<param name="g_flag" value="3" />
</antcall>
<antcall target="PAIR_CONN">
<param name="g_flag" value="4" />
</antcall>
<antcall target="PAIR_CONN">
<param name="g_flag" value="0" />
</antcall>
</parallel>
</target>

Resources