How to use PXRedirectToUrlException in Acumatica - acumatica

In Stock Items screen we created a button and on this button click we are downloading some certificates from third party and storing into files section. we also created a button GET CERTIFICATE on this button action, we want user to redirect to GetFile.ashx screen. Like how standard Acumatica will take us when we click on link from Files popup.
We are using 2019 R1, here is my code sample:
throw new PXRedirectToUrlException(string.Format("~/Frames/GetFile.ashx?fileID={0}", fileId), "Certificate") { Mode = PXBaseRedirectException.WindowMode.NewWindow };

It looks there is a good example of this found in SOShipmentEntry (PrintCarrierLabels method) if you have the fileid already:
string targetUrl = PXRedirectToFileException.BuildUrl(mergedFile.UID);
throw new PXRedirectToUrlException(targetUrl, "Print Labels");
You can also use PXRedirectToFileException if you have the FileInfo object:
throw new PXRedirectToFileException(file, true);
These might open/download the file as I am not sure of the results. These are examples I found in the Acumatica source for working with fileid.
If you really want the user to download the file this is a good post: How to add Button for downloading excel file in Acumatica

Related

Unable to view or edit the files in ms office software from our web app using ActiveX control

I have Microsoft office integration with my web application where there is option to view and edit the uploaded files by clicking on an edit button which opens the file in the appropriate Microsoft software. Such as if a word file is uploaded then on clicking the edit button, the file should get opened in the Microsoft word software. I am using ActiveX controls for this functionality for opening the document using the below code on IE,
spEditObj.EditDocument(FileURL);
I have verified the FileURL is correct as on clicking the edit button, the breakpoint control was coming here where this FileURL value is coming correct and this function [ spEditObj.EditDocument(FileURL) ] is returning true value but still the file content is not being displayed.
The issue is that when I am clicking on the edit button, its opening the Microsoft word application but the file content is not being displayed.
I am guessing that it is due to improper installation of MS office or may be due to missing some dll files.
Can you please suggest me the fix for this ?
Thankyou.
Please check the file permission, whether you have permission to read and write it.
I have create a sample using the following code, it works well on my machine, you could refer to it:
<script src="Scripts/jquery-1.10.2.js"></script>
<script type="text/javascript">
$(function () {
$('a').on('click', function () {
var file = $(this).attr('href');
// This is what does the work.
try {
try {
// get Word Active-X Object if Word is open.
var word = GetObject('', "Word.Application");
}
catch (e) {
// create new Word Active-X Object.
var word = new ActiveXObject("Word.Application");
}
word.Visible = true; // Make sure Word is visible.
word.Documents.Open(file); // Open the file you want.
}
catch (e) {
alert(e.description);
}
// End work.
return false;
});
});
</script>
Readiness.docx
[Note]we need to enable the Initialize and script active x controls is not marked safe for scripting (IE browser Tools Menu -> Internet Options -> Security -> Custom level -> enable the Initialize and script active x controls is not marked safe for scripting), please check and enable it.
Yeah.. this issue seems to be due to authentication problem for the WebDAV Directory. Resolved it on my own by changing the authentication of the WebDAVDir from basic authentication to windows authentication from Internet Information Services (IIS) Manager.

How to open a hyperlink in separate browser tab in Coded UI

I have three different Hyperlinks on a web page
Planning.
Solutions.
Contact Us.
I want to open them in separate browser tab one by one using codedUI.
i have written the above code to obtain the list of Hyperlink
HtmlControl Hyperlink = new HtmlControl(browser);
Hyperlink.SearchProperties.Add(HtmlControl.PropertyNames.ControlType,"Hyperlink");
UITestControlCollection controls = Hyperlink.FindMatchingControls();
foreach(UITestControl control in controls)
{
if (control is HtmlHyperlink)
{
HtmlHyperlink link = (HtmlHyperlink)control;
if(link.InnerText=="Planning"|| link.InnerText== "Solutions")
{
//separate Tab logic goes here
}
}
}
I need the help related to opening a hyperlink in new browser tab. Is it possible in CodedUI ?
By default if you click the mouse middle button (or click the scroll wheel), it opens a link in new tab. I would modify your code as below in this case,
if(link.InnerText=="Planning"|| link.InnerText== "Solutions")
{
//Open Link in New tab, by clicking middle button
Mouse.Click(link, MouseButtons.Middle);
}
You can do this a couple different ways. I would use #Prageeth-Saravan 's approach first to see if it works because it's easier and actually tests your UI. You could also:
Get the URL from the found link control
Send the "New tab" keyboard shortcut
Reinstantiate your browser window object to be sure it's pointing to the new tab
Navigate to that URL
The reason why I bolded step 3 is regardless of approach, if you intend to assert or interact with anything in a new tab you're going to have to remember that the CodedUI software will still be "Looking" at the old tab until you reinitialize it.

Lotus Notes - Remove icon from workspace after the opening of the .nsf

On my page in a main Lotus app I have 3 buttons which are opening 3 databases.
The formula code is:
#Command([FileOpenDatabase]; "ServerName":"Testing.nsf"; ""; ""; "1"; "1" );
#Command([WindowWorkspace]);
#Command([FileDatabaseRemove]);
It works, but It gives me a message: Remove selected item(s)? And I click yes and then finally it is ok. Is there any chance, to remove-it without that messagebox to appear?
Thanks
You don't have to remove database icon from workspace because you already set parameter temporary to "1". This parameter avoids creating an icon opening the database.
So, the only thing you have to do is to delete the second and third line of your code. Then your database gets open without creating an icon on workspace.

Sharepoint links - how to open in new tab/Window

I've noticed with Sharepoint 2010, many of the links do not the support open in new tab/window feature. For example, items on the quick menu do not. Is it possible to enable?
Use the JavaScript function to open a new window in SharePoint 2010.
Create the function to open your target window as sample provide below.
function load_url(externallink)
{
window.open(externallink,target='_blank')
}
Place the function load_url in JavaScript file
Click site actions, select manage content and structure.
Suppose you want to change the links in the page
http://someserver/sites/Dev/Help/HelpLinks/AllItems.aspx
Then select the List named HelpLinks in the sub site Help. Dev will be the top most node(site). Help will be a sub site and inside Help you can find List by name HelpLinks.
All the links in the page and their title will be displayed
Select the title of link which you want to open in new tab and right click.
Select Edit properties. Then in the URL field and call the function as javascript:load_url('http://www.google.co.in'); instead of http:// www.google.co.in
Or Else
Suppose you want to change the links in the below URL.
URL: http:// someserver/sites/Dev/Help/HelpLinks/AllItems.aspx
Go To
open to the link http:// someserver/sites/Dev/Help/HelpLinks/AllItems.aspx
You will find the columns of the List (Title Column, URL column, Summary etc).
Select the Title and click Edit property which you want to edit
Then in the URL field and call the function as javascript:load_url('http://www.google.co.in'); instead of http:// www.google.co.in
This answer is a recap of this article and is not an answer I came up with: http://sharepointsolutions.blogspot.com/2007/09/make-selected-links-in-links-list-open.html
Step 1: Add #openinnewwindow to the end of all hyperlinks you want to open in new window.
Step 2: Then you will need to add the follow script to your SharePoint pages.
[script language = "JavaScript"]
//add an entry to the _spBodyOnLoadFunctionNames array
//so that our function will run on the pageLoad event
_spBodyOnLoadFunctionNames.push("rewriteLinks");
function rewriteLinks() {
//create an array to store all the anchor elements in the page
var anchors = document.getElementsByTagName("a");
//loop through the array
for (var x = 0; x < anchors.length; x++) {
//does this anchor element contain #openinnewwindow?
if (anchors[x].outerHTML.indexOf('#openinnewwindow') > 0) {
//store the HTML for this anchor element
oldText = anchors[x].outerHTML;
//rewrite the URL to remove our test text and add a target instead
newText = oldText.replace(/#openinnewwindow/, '" target="_blank');
//write the HTML back to the browser
anchors[x].outerHTML = newText;
}
}
}
[/script]
Whats the 'Quick menu'? Do mean list item context menu or something else? Can you post a screenshot?
There are two types of links used.
Normal HTML anchors - You can hold down the CTRL key when clicking.
JavaScript links (menus and such) the CTRL key doesn't work. If you're working with the Edit/View forms then this may be of interest
SharePoint - Editing The SharePoint List Item Menu
Especially look for Part II where it talks about changing this behaviour in List Settings > Advanced Settings > Dialogs
This is actually an Internet Explorer specific bug. The navigation links in SharePoint 2010 are regular links but have two nested span tags around the text of the link. This confuses IE which doesn't realise that the text you are right-clicking up is a link and so doesn't give the correct context menu. If you right-click just to the left of the text of the link (the cursor should still show as the "hand") the context menu appears as expected.
For Sharepoint 2013, I used Keith's code with a delayed call.
<script type="text/javascript">
// Add an entry to the _spBodyOnLoadFunctionNames array
// so that our function will run on the pageLoad event
_spBodyOnLoadFunctionNames.push("rewriteLinks");
function rewriteLinks() {
$('a').attr("target","_blank");
}
</script>
In the SharePoint Wiki Editor, you can click the "From Address" Link you added, and a LINK menu will appear in the ribbon bar. Inside that, you can click "Open in New Tab" It's not exactly New Window, but it's close and easy.
Add this to the end of the link.
#openinnewwindow
example: http://www.bing.com**#openinnewwindow

How to control application from WebBrowser Control?

I've googled it, but came out empty. And the worst thing is that I know it is possible.
Anyway, I'm developing an application that uses the WebBrowser control to display information regarding an object (like Outlook does with the Rules and Alerts dialog box).
My question is how do I do for the click on a, say, hyperlink in the WebBrowser execute some function within the Windows Form?
For instance, say I have a link like this and when I click it I want the application to display an specific form, like the Outlook does when you click on hyperlinks like People and Distribution List
This looks useful: How to: Implement Two-Way Communication Between DHTML Code and Client Application Code
ChrisW's answer will work, but there's another way if you're just relying on hyperlinks.
In Comicster, I have links in my WebBrowser control like this:
New Collection
And then in the WebBrowser's Navigating event, I have some code to check if the user has tried to navigate to an "action:" link, and intercept it:
private void webBrowser1_Navigating(object sender,
WebBrowserNavigatingEventArgs e)
{
if (e.Url.Scheme == "action")
{
e.Cancel = true;
string actionName = e.Url.LocalPath;
// do stuff when actionName == "FileNew" etc
}
}
With a little bit of code you can even parse the URL parameters and "pass them through" to your host application's action, so I can do things like:
Edit this issue
... which will open a properties dialog for the issue with ID 1.

Resources