Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

ScriptMaster fails compiling script

Featured Replies

Hi, I am new to ScriptMaster, so it could be, that I am doing something wrong. But let's start:

I added a new script module with content as following:

com.fasterxml.jackson.databind.ObjectMapper mapper = new com.fasterxml.jackson.databind.ObjectMapper();
java.util.Map<String, String> map = mapper.readValue(json, Map.class);

net.codecrete.qrbill.generator.Bill bill = new net.codecrete.qrbill.generator.Bill();
bill.setAccount(map.get("iban"));
bill.setAmountFromDouble(Double.valueOf(map.get("amount").doubleValue());
bill.setCurrency(map.get("currency"));

// Set creditor
net.codecrete.qrbill.generator.Address creditor = new net.codecrete.qrbill.generator.Address();
creditor.setName(map.get("creditor.name"));
creditor.setAddressLine1(map.get("creditor.address"));
creditor.setAddressLine2(map.get("creditor.city"));
creditor.setCountryCode(map.get("creditor.country"));
bill.setCreditor(creditor);

// more bill data
bill.setReference(map.get("reference"));
bill.setUnstructuredMessage(map.get("message"));

// Set debtor
net.codecrete.qrbill.generator.Address debtor = new net.codecrete.qrbill.generator.Address();
debtor.setName(map.get("debtor.name"));
debtor.setAddressLine1(map.get("debtor.address"));
debtor.setAddressLine2(map.get("debtor.city"));
debtor.setCountryCode(map.get("debtor.country"));
bill.setDebtor(debtor);

// Generate QR bill
return new net.codecrete.qrbill.generator.QRBill().generate(bill);

I pass the following parameter:

{
 	"iban" : "CH4431999123000889012",
	"amount" : "199.95",
    "currency" : "CHF",
	"creditor.name" : "Robert Schneider AG",
    "creditor.address" : "Rue du Lac 1268/2/22",
	"creditor.city" : "2501 Biel",
    "creditor.country" : "CH",
	"reference" : "210000000003139471430009017",
    "message" : "Abonnement für 2020",
    "debtor.name" : "Pia-Maria Rutschmann-Schnyder",
    "debtor.address" : "Grosse Marktgasse 28",
    "debtor.city" : "9400 Rorschach",
    "debtor.country" : "CH",
}

I use these jars: Jackson-Databind-2.12.4.jar, Pdfbox-2.0.24.jar, Qrbill-Generator-2.5.3.jar and Qrcodegen-1.7.0.jar

when I run the script I get the error

Compilation failed: startup failed:

Script1.groovy: 29: unexpected token:  @ line 29, column 67.

   rator.QRBill().generate(bill);

                                 ^



1 error



Parameters:
json={
 	"iban" : "CH4431999123000889012",
	"amount" : "199.95",
    "currency" : "CHF",
	"creditor.name" : "Robert Schneider AG",
    "creditor.address" : "Rue du Lac 1268/2/22",
	"creditor.city" : "2501 Biel",
    "creditor.country" : "CH",
	"reference" : "210000000003139471430009017",
    "message" : "Abonnement für 2020",
    "debtor.name" : "Pia-Maria Rutschmann-Schnyder",
    "debtor.address" : "Grosse Marktgasse 28",
    "debtor.city" : "9400 Rorschach",
    "debtor.country" : "CH",
}

---Script---
Script:
com.fasterxml.jackson.databind.ObjectMapper mapper = new com.fasterxml.jackson.databind.ObjectMapper();
java.util.Map<String, String> map = mapper.readValue(json, Map.class);

net.codecrete.qrbill.generator.Bill bill = new net.codecrete.qrbill.generator.Bill();
bill.setAccount(map.get("iban"));
bill.setAmountFromDouble(Double.valueOf(map.get("amount").doubleValue());
bill.setCurrency(map.get("currency"));

// Set creditor
net.codecrete.qrbill.generator.Address creditor = new net.codecrete.qrbill.generator.Address();
creditor.setName(map.get("creditor.name"));
creditor.setAddressLine1(map.get("creditor.address"));
creditor.setAddressLine2(map.get("creditor.city"));
creditor.setCountryCode(map.get("creditor.country"));
bill.setCreditor(creditor);

// more bill data
bill.setReference(map.get("reference"));
bill.setUnstructuredMessage(map.get("message"));

// Set debtor
net.codecrete.qrbill.generator.Address debtor = new net.codecrete.qrbill.generator.Address();
debtor.setName(map.get("debtor.name"));
debtor.setA...

But looking at the javacode everything should be ok! What could be the problem here? Thank you!

  • Author

Solved (better: copied the content of the script and pasted it again, now it runs).

 

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.