Copy link to clipboard
Copied
How can I check if a photo is uploaded in an image field using a script? I want to show it in a text field as a status.
Copy link to clipboard
Copied
That's exactly what my script does. You need a trigger. The mouseup action of the button is the trigger. Calculation scripts only change when field values change. An image added to a button field is not a value change. What do you mean "prompt"? If you insist on making this a custom calculation script in the text field you would change the script to the following (assuming "Button1" is the image field name):
var icn=this.getField("Button1").buttonGetIcon();
var status="Has image";
try{util.iconStreamFromIcon(icn)}catch(e){status="Does not have image."}
event.value=status;
You will still need to modify the mouseup action of the image field so the change happens immediately by adding this line of code to the mouse up action:
this.calculateNow();
Copy link to clipboard
Copied
In the mouse up action of the image you should this script:
event.target.buttonImportIcon();
Assuming the name of your text field is "Status", add the following script after the script above in the mouse up action of the button/image field:
var icn=event.target.buttonGetIcon();
var status="Has image";
try{util.iconStreamFromIcon(icn)}catch(e){status="Does not have image."}
this.getField("Status").value=status;
Copy link to clipboard
Copied
Copy link to clipboard
Copied
That's exactly what my script does. You need a trigger. The mouseup action of the button is the trigger. Calculation scripts only change when field values change. An image added to a button field is not a value change. What do you mean "prompt"? If you insist on making this a custom calculation script in the text field you would change the script to the following (assuming "Button1" is the image field name):
var icn=this.getField("Button1").buttonGetIcon();
var status="Has image";
try{util.iconStreamFromIcon(icn)}catch(e){status="Does not have image."}
event.value=status;
You will still need to modify the mouseup action of the image field so the change happens immediately by adding this line of code to the mouse up action:
this.calculateNow();
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Both of my scripts do exactly that. One is a mouse up event in the button/image field. The other is a calculation event in the text field. Choose one or the other. If you chose the calculation script you need to add a this.calculateNow() to the button/image script. What do you mean "upload an image"? What do you want the text field to say?
Copy link to clipboard
Copied
Ow sorry, I get it now. I was just confused. But it's working like I want it. Thank you very much. The this.CalculateNow() made it work. 😊