1 Conceptual Map of Scripts

2 Script Structure
Mobile / Scripts / Scripts
Mobile CRM / System / Scripts / Scripts
Mobile / System / Scripts / Scripts
Sistema / Scripts / Scripts
The APPS system takes advantage of JavaScript to customize application actions and forms. At various points, each installation will require its own customizations, so as to be able to perform actions online with the application. These points may include loading, assignment validation, document editing, new customer registration, document line editing, payment verification, or printing. The apps_scripts table contains all Java programs synchronized to the device, which are interpreted by the application.
apps_sys_scripts | |
---|---|
Label | Description |
Code | Script code
|
Description | Script information |
Script | Script |
Status | Status
|
Creator | User who first entered/created the record
|
Registration date | Log entry date
|
Updater | Last user to modify the record
|
Update date | Date of most recent registry modification
|
3 Task Scripts
3.1 apps_sfa_task_assign.save
The script with the code apps_sfa_task_assign.save
is executed when users modify an assignment from their device.
The program must return a [true/false]
boolean value.
Example: This script requires the user to indicate a reason when modifying an assignment date.
// Indicate reason for assignment modification import android.widget.Toast; try{ EditText ed_ch_motive = caller.get("assign_ch_reason").getEditText(); String ch_motive = ed_ch_motive.getText().toString(); if(ch_motive.equals("1")){ Toast.makeText(context, "Indicate a Reason ", Toast.LENGTH_LONG).show(); return false; } }catch (Exception ex) { System.err.println("Generating new manual assignment"); } return true;
Once a reason is indicated, press the OK button. The script will return a 'true', and the action can be performed. |
---|
![]() |
Pressing an assignment will bring up a system dialog, used modify the date, notes and a combo. The reason for modification must be indicated here. |
---|
![]() |
3.2 apps_sfa_task_assign.validate
Task execution must be correct at every point to maintain logic. To minimize possible employee errors, certain scripts are used as in situ
checkers of the information
supplied by the employee.
These "scripts" help perform checks such as:
- Avoid picking up or delivering more packages than stipulated.
- Avoid picking up or delivering fewer packages than stipulated.
- Avoid errors in which packages to pick up or deliver, etc.
When the script with the apps_sfa_task_assign.validate
code is executed, the system performs an automatic check. The program must return a [true/false]
boolean.
A set of functions intrinsic to the script can be used.
Set of functions intrinsic to the script which can be used:
// *********************** // Header Functions // *********************** /** * Obtain PK. * Example: int type = caller.getAssignType() * * Used for BSH caller Validate * @return */ public int getAssignType(){ return m_assign_type; } /** * * @return */ public int getAssignNumber(){ return m_assign_number; } /** * * @return */ public String getAssignUser(){ return m_assign_user; } /** * Obtain assignment task code. * Example: String m_task_code = caller.getTaskCode() * * Used for BSH caller Validate * @return */ public String getTaskCode(){ return m_task_code; } /** * Obtain assignment customer code. * Example: String m_assign_customer = caller.getSurveyCustomer() * * @return */ public String getSurveyCustomer() { return m_assign_customer; } /** * Obtain assignment source code. * Example: String m_assign_docori = caller.getSurveyDocori() * * @return */ public String getSurveyDocori() { return m_assign_docori; } // *********************** // Question Functions // *********************** /** * Obtain set of Object Questions in an Array. * Example: m_questions = caller.getQuestions(); * Used for BSH caller Validate to interact with questions and their values * @return */ public ArrayList<Question> getQuestions(){ return m_questions; } // Example: // GET THE QUESTIONS m_questions = caller.getQuestions(); // Navigate from question to question for (Question q : m_questions) { if (q.isVirtual()) continue; String m_ask_code = q.getAskCode(); String m_ask_text = q.getAskText(); } * Public Methods * ============== * * void lock() * void unlock() * boolean isLocked() * * String toString() * void setInputRequired(boolean required) * * void setTextView(TextView text) * void setImageView(ImageView image) * TextView getTextView() * TextView getLabelView() * boolean isNull() * boolean isVirtual() * boolean isPrintable() * boolean isBinary() * boolean isRequired() * String getGroupCode() * String getTaskCode() * String getAskCode() * int getAskSeqno() * int getAskType() * String getAskCombo() * String getAskText() * int getIndex() * String getValue() * * DATA SETTERS (Public) * ============ * void setValue(String value) * void setInitialValue(String value) * void setBytes(byte[] value) * void setImageBytes(byte[] temp) * void setImageBytes(Uri uri) * void setPOSOrderIcon()
In this package delivery and pick-up example, the system will perform a final check if packages have been picked up and delivered.
This will be executed through the script apps_sfa_task_assign.validate
when the employee presses the End Task button.
// Validate the Survey before closing. import java.util.ArrayList; import android.text.Html; import android.app.AlertDialog; import android.content.DialogInterface; import android.view.Gravity; import android.widget.Toast; import android.net.Uri; import android.util.Base64; import android.database.Cursor; import deister.android.apps.Constants; import deister.android.apps.Config; import deister.android.apps.modules.sfa.question.Question; import deister.android.apps.R; try{ // GET THE TASK CODE String m_task_code = caller.getTaskCode(); // GET ASSIGNMENT PK Integer m_type = Integer.valueOf(caller.getAssignType()); Integer m_num = Integer.valueOf(caller.getAssignNumber()); String m_user = caller.getAssignUser(); // GET QUESTIONS m_questions = caller.getQuestions(); // Monthly operations (manual) if(m_task_code.equals("DELIVERY")){ String m_livre=""; m_livre = m_questions.get(2).getValue(); //for(idx=1;idx<m_questions.size();idx++){ // if(m_questions.get(idx).getAskCode().equals("delivery.livre")){ // m_livre = m_questions.get(idx).getValue(); // } //} Integer m_num_bul = 0; Integer m_num_bul_read = 0; //PACKAGES IN ASSIGNMENT Cursor cur_bult = context.getContentResolver().query( Constants.tableUri(Constants.tableOf(Constants.TABLE_SFA_TASK_ASSIGN_EANS)), new String[] {"*"}, " assign_user= ? AND assign_type= ? AND assign_number= ? ", new String[] {m_user,String.valueOf(m_type),String.valueOf(m_num)}, null ); while (cur_bult.moveToNext()) { m_num_bul = m_num_bul +1; } cur_bult.close(); //PACKAGES SCANNED Cursor cur_bult_read = context.getContentResolver().query( Constants.tableUri(Constants.tableOf(Constants.TABLE_SFA_TASK_RESL_EANS)), new String[] {"*"}, " assign_user= ? AND assign_type= ? AND assign_number= ? ", new String[] {m_user,String.valueOf(m_type),String.valueOf(m_num)}, null ); while (cur_bult_read.moveToNext()) { m_num_bul_read = m_num_bul_read +1; } cur_bult_read.close(); if(m_livre.equals("Oui")){ if(m_num_bul > m_num_bul_read){ AlertDialog alertDialog = new AlertDialog.Builder(context).create(); alertDialog.setIcon(R.drawable.alert_warning); alertDialog.setTitle(Html.fromHtml("<font color='#FF0000'><b>Livraison incomplète!!!</font>")); alertDialog.setMessage(Html.fromHtml("<font color='#58FA58'>PAQUETS À LIVRER:"+ m_num_bul +"<br/><br/>PAQUETS LIVRÉS:"+ m_num_bul_read)); alertDialog.setButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.cancel(); } }); alertDialog.show(); return false; } } if(m_livre.equals("Partiel")){ if(m_num_bul_read == 0){ AlertDialog alertDialog = new AlertDialog.Builder(context).create(); alertDialog.setIcon(R.drawable.alert_warning); alertDialog.setTitle(Html.fromHtml("<font color='#FF0000'><b>Livraison partielle!!!</font>")); alertDialog.setMessage(Html.fromHtml("<font color='#58FA58'>PAQUETS À LIVRER:"+ m_num_bul +"<br/><br/>PAQUETS LIVRÉS:"+ m_num_bul_read)); alertDialog.setButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.cancel(); } }); alertDialog.show(); return false; } } } // Monthly operations (manual) if(m_task_code.equals("PICKUP")){ String m_collecte=""; m_collecte = m_questions.get(2).getValue(); //for(idx=1;idx<m_questions.size();idx++){ // if(m_questions.get(idx).getAskCode().equals("delivery.livre")){ // m_livre = m_questions.get(idx).getValue(); // } //} Integer m_num_bul = 0; Integer m_num_bul_read = 0; //PACKAGES IN ASSIGNMENT Cursor cur_bult = context.getContentResolver().query( Constants.tableUri(Constants.tableOf(Constants.TABLE_SFA_TASK_ASSIGN_EANS)), new String[] {"*"}, " assign_user= ? AND assign_type= ? AND assign_number= ? ", new String[] {m_user,String.valueOf(m_type),String.valueOf(m_num)}, null ); while (cur_bult.moveToNext()) { m_num_bul = m_num_bul +1; } cur_bult.close(); //PACKAGES READ Cursor cur_bult_read = context.getContentResolver().query( Constants.tableUri(Constants.tableOf(Constants.TABLE_SFA_TASK_RESL_EANS)), new String[] {"*"}, " assign_user= ? AND assign_type= ? AND assign_number= ? ", new String[] {m_user,String.valueOf(m_type),String.valueOf(m_num)}, null ); while (cur_bult_read.moveToNext()) { m_num_bul_read = m_num_bul_read +1; } cur_bult_read.close(); if(m_collecte.equals("Oui")){ if(m_num_bul > m_num_bul_read){ AlertDialog alertDialog = new AlertDialog.Builder(context).create(); alertDialog.setIcon(R.drawable.alert_warning); alertDialog.setTitle(Html.fromHtml("<font color='#FF0000'><b>Collecté incomplete!!!</font>")); alertDialog.setMessage(Html.fromHtml("<font color='#58FA58'>PAQUETS POUR RECUEILLIR:"+ m_num_bul +"<br/><br/>PAQUETS COLLECTÉS:"+ m_num_bul_read)); alertDialog.setButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.cancel(); } }); alertDialog.show(); return false; } } if(m_collecte.equals("Partiel")){ if(m_num_bul_read == 0){ AlertDialog alertDialog = new AlertDialog.Builder(context).create(); alertDialog.setIcon(R.drawable.alert_warning); alertDialog.setTitle(Html.fromHtml("<font color='#FF0000'><b>Collecté partielle!!!</font>")); alertDialog.setMessage(Html.fromHtml("<font color='#58FA58'>PAQUETS POUR RECUEILLIR:"+ m_num_bul +"<br/><br/>PAQUETS COLLECTÉS:"+ m_num_bul_read)); alertDialog.setButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.cancel(); } }); alertDialog.show(); return false; } if(m_num_bul_read == m_num_bul){ AlertDialog alertDialog = new AlertDialog.Builder(context).create(); alertDialog.setIcon(R.drawable.alert_warning); alertDialog.setTitle(Html.fromHtml("<font color='#FF0000'><b>Livraison non partielle!!!</font>")); alertDialog.setMessage(Html.fromHtml("<font color='#58FA58'>PAQUETS POUR RECUEILLIR:"+ m_num_bul +"<br/><br/>PAQUETS COLLECTÉS:"+ m_num_bul_read)); alertDialog.setButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.cancel(); } }); alertDialog.show(); return false; } } }catch (Exception ex) { Toast.makeText(context, "Trying to Validate, but an error ocurred", Toast.LENGTH_LONG).show(); } return true;
Example: Task where the user must indicate electronic meter readings. This script checks that the value read and reported by the user is higher than the last value read. After checkout, the consum field (response) is set to the values subtracted.
// Validate Survey before closing. import java.util.Date; import java.util.ArrayList; import android.widget.Toast; import deister.android.apps.modules.sfa.question.Question; try{ // GET TASK CODE String m_task_code = caller.getTaskCode(); // GET QUESTIONS m_questions = caller.getQuestions(); // Monthly operations (manual) if(m_task_code.equals("1-049")){ // SURVEY QUESTIONS // // ask_code Type Text // ----------------------------------------------------------------- // PR_1 No-entry Kilometros // PR_2 Timestamp Dietas // ----------------------------------------------------------------- Integer m_pr_1 = Integer.valueOf(m_questions.get(0).getValue()); // Check that the kilometers value is above 10 if(m_pr_1 < 10){ Toast.makeText(context, "Insufficient km", Toast.LENGTH_LONG).show(); return false; } } }catch (Exception ex) { Toast.makeText(context, "Trying to Validate, but an error occurred", Toast.LENGTH_LONG).show(); } return true;