Application Studio - Disable Print Button

Hello,

I am trying to convert the windows client customizations to their corresponding web versions via Application Studio.

One customization is disabling the Job Traveler print in the toolbar area if the PersonID is < 101.

So, I did the below, but it isn’t working. Does sysTools relate to the icons in the action section of the header?

Below are screenshots of the data rule and the section of the header I am trying to hide the print button from (Job Entry btw). Thank you for your time!

Print icon still visible:
image

Here is the windows client form code that performed the action

private void edvJobHead_EpiViewNotification(EpiDataView view, EpiNotifyArgs args)
{
	// ** Argument Properties and Uses **
	// view.dataView[args.Row]["FieldName"]
	// args.Row, args.Column, args.Sender, args.NotifyType
	// NotifyType.Initialize, NotifyType.AddRow, NotifyType.DeleteRow, NotifyType.InitLastView, NotifyType.InitAndResetTreeNodes
	if ((args.NotifyType == EpiTransaction.NotifyType.Initialize))
	{
		if ((args.Row > -1))
		{
			var personIDstr = view.dataView[args.Row]["PersonID"].ToString();
			if(!string.IsNullOrEmpty(personIDstr))
			{
				int personID = 0;
				if (int.TryParse(personIDstr, out personID))
				{
					// Hide the Print Job Traveler if the ID < 101
					if (personID < 101)
					{
						baseToolbarsManager.Tools["JobTravPrint"].SharedProps.Visible = false;
					}
					else
					{
						baseToolbarsManager.Tools["JobTravPrint"].SharedProps.Visible = true;
					}
				}
			}
		}
	}
}

Hi Rob,

Have you checked to see if that Dataview is populating with any data when you load the Job Traveler form? Just because the dataview is selectable, it doesn’t mean it is populating with any information.

You can launch a trace in the browser by hitting F12 it slides out a panel to show the debugging window (you can also have it pop out as its own window if you want). Once the screen is launched, go back to the Kinetic screen, and click into a data field. Press Ctrl+Alt+8 to enable debugging mode in the trace window and press Ctrl+Alt+V to show all dataviews. Under the Console tab, you should see all the dataviews on the screen and you can expand them to see what data is available to use.
If the data you are looking for is not there, I create a BAQ and map the BAQ to a dataview, maybe on load of the screen? Find an event that makes sense, run the BAQ, populate the dataview, then do your comparision from that dataview.

Hope that helps some

2 Likes

Thank you very much for the help! I figured a data rule would “just work” but I am still learning the Kinetic Application Studio process (very new to it).

But you made an excellent point, so I figured instead of trying to use a data rule, I’d use an event.

My thing is, I don’t think I am doing it correctly.

Here is my event:

We can see it successfully shows the PersonID
image

But the print button remains visible. Here is how I setup property-set:

I got the ID from clicking the header of the Main form (which I learned about thanks to @hmwillett)

However, I also see there is an EpiBinding for the tool: JobHead.JobTravPrintTool

I am going to see if I can use a data rule for this binding…

Thanks!

Yeah data rule didn’t work either…

I changed the event to set the Hidden prop to true, but that didn’t work either, though you can see it happening in the event log:

Works for me with “No Condition”

Before:
image

Rule:

After:
image

So, I think your action is okay… but your condition may not work.

PersonID is a string. You can try wrapping it in quotes and see if it works on a one-off basis. But your original request of using “less than” may not work as you’re not dealing with a numeric value.

3 Likes

I guess this makes sense as your original code was converting it to an int to do the evaluation:

image

2 Likes

Single quote should work for less than condition:

2 Likes

I would be extremely hesitant to compare strings that way.
A much safer bet is to create a small utility function to convert the ID to an integer, send it back and then use that to compare in the rule.

2 Likes

m’Kay… now I’m intrigued.

I don’t necessarily subscribe to the “if it works, it works” mentality… but, can you learn me on why you have reservations on the above approach.

Explain Yourself Giancarlo Esposito GIF by Breaking Bad

The less-than operator on strings does a lexicographical comparison on the strings. This compares strings in the same way that they would be listed in dictionary order, generalized to work for strings with non-letter characters.

Dictionary order != numerical order.

Example:
Because 2 comes before 7 in “dictionary order”, it’s considered less than 7 even though it’s 22.

3 Likes

Thank you @dcamlin and @itsme! I should have looked at the table to check the data type, fail on my part :slight_smile:

That is very true @hmwillett, I can say though I did test the data rule using values of ‘’, ‘035’, ‘102’, and the less than operator on the value using single quotes did work.

I would, however as I come from a C# background, like to implement the function as you described, but I don’t know how to have an event set the value and then check it in the data rule. Do you have a thread out there exampling how to do something like this?

2 Likes

Name these whatever you want:
Create a function library called ‘Utilities.’
Add a function called ‘StrToInt.’
Give it an In parameter of a string such as InStr.
Define and Out parameter of integer such as OutInt.
Maybe include a boolean Out parameter called Success.

Set up the code as such:

Success = int.TryParse(personIDstr, out OutInt);

Promote it.

You can do this in the same trigger you have currently shown.
Include a kinetic-function or erp-function (name is version dependent to add some confusion. :slight_smile: ) widget.
Include a row-update widget after your function.
Set a runtime variable like TransView.IntPerCon to {actionResult.OutInt}
Use that TransView.IntPerCon in your rule to compare.

5 Likes

That’s because 0 is less than 1.

If you try ‘35’ < ‘102’ it will be false.

1 Like

Thank you!

learning-learnding

Thank you for the information.
Learning Brits GIF by BRIT Awards

1 Like

So I liked the Utilities functions, I’ve actually been building function libraries that are extensions of forms (like I built a SalesOrderExt library).

I created a general StrToInt function to be reused, so the naming is a bit different but follows your approach:


image

I then setup an event to run the function and store it as you mentioned:


Then updated the data rule:

But it’s not working, did I miss a step?

I did test the function library using the REST API Help, so I know it is working as desired.

Thank you!

I would look at the Dev Tools as this point to check the values of the flow.
Make sure the payload sent to your function has the proper value being sent.
Validate the response is as expected.

Dump the views (CTRL+ALT+V), expand System Views, and validate that actionResult has a value. It may show null here. Assuming you had debugging turned on (CTRL+ALT+8) check the console. You should see some events in there for your row-update showing the values of actionResult at the time.

Thanks, I should have thought to do that. Still getting used to all this, I really appreciate your time today!

The result in the console is rather confusing, I know the PersonID value exists as I had the dialog showing me the value beforehand. From the below, it looks like things are undefined, but yet, actionResult.output is 25, which is the correct value for this record (actual string value in the DB for this record is ‘025’):

Could it be a timing issue where my event is occurring post the data rule performing its check?

If you dump the views does your variable in Trans view show up with a value of 25?

It doesn’t show the value, so something must be going on with the setting… let me do some debugging…