ServiceNow storing and calling upon glide scripts - html

I am creating a front end portal in ServiceNow that requires using g:evaluate to call on variables from different tables.
For example:
<g:evaluate var="jvar_user_name">
var gr = new GlideRecord('sys_user');
gr.get('sys_id', gs.getUserID());
gr.first_name;
</g:evaluate>
Is there a way to store a bunch of these somewhere and then call upon them as needed, much like UI Scripts for JS and Style Sheets for CSS? If so, how would I go about doing this?
Thanks!

Yes you should be able to do this by using UI Macros.
You could create a UI Macro called set_user_name_var like below:
<?xml version="1.0" encoding="utf-8"?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<g:evaluate var="jvar_user_name">
var gr = new GlideRecord('sys_user');
gr.get('sys_id', gs.getUserID());
gr.first_name;
</g:evaluate>
</j:jelly>
And then invoke the UI Macro any place where you can write jelly code, like so:
<g:set_user_name_var />
or alternatively:
<g:macro_invoke macro="set_user_name_var" />
And from that point on, the jvar_user_name jelly variable will exist and be able to be accessed.
For example:
<?xml version="1.0" encoding="utf-8"?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<g:set_user_name_var />
${jvar_user_name}
</j:jelly>

Related

Hybris backoffice - display of attributes in correct tab

In backoffice, for B2BUnit and B2BCustomer models, There are some important attributes that are displaying under "Administration" tab.
But I would like to show it under "Properites" or "General" tab. What configuration I need to change?
I hope you already have a custom backoffice extension, if not then follow this tutorial to create one.
Now, In your custom backoffice extension, you can find the file *backoffice-backoffice-config.xml. In this file, you can define how & where you want to populate your custom attribute. You need to declare it for the editor-area component like below.
<context merge-by="type" parent="Customer" type="B2BCustomer" component="editor-area">
<editorArea:editorArea xmlns:editorArea="http://www.hybris.com/cockpitng/component/editorArea">
<editorArea:tab xmlns="http://www.hybris.com/cockpitng/component/editorArea" name="hmc.properties">
<section name="hmc.section.your.custom.section">
<attribute qualifier="yourAttribute"/>
</section>
</editorArea:tab>
</editorArea:editorArea>
</context>
Here you can define the new custom section (hmc.section.your.custom.section) or use any existing section name. For the custom section, you need to define its value in the in labels_en.properties (like a way for each language labels_*.properties) file.

How to change color of TimePickerAndroid in React Native?

Is it possible to change default color of the TimePickerAndroid component ?
You would have to change it from the styles.xml file of android. Here's what you do:
1) Open up styles.xml: "android/app/src/main/res/values/styles.xml"
2) you'll need to add a few lines:
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="android:timePickerDialogTheme">#style/Dialog.Theme</item>
</style>
<style name="Dialog.Theme" parent="Theme.AppCompat.Light.Dialog">
<item name="colorAccent">#FF0000</item>
<item name="android:textColorPrimary">#0000FF</item>
</style>
In styles.xml you should already have:
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
If you do just add the remaining lines. If not go ahead and add them.
4) Lastly, just recompile the app. "react-native run-android". You should see the color change right away.
Using React-native, unfortunately no.
However, by changing some java files in RN and using this solution from SO you might be able to do it.
If you succeed doing this, I suggest you create a Pull Request on RN's repository as it might be very useful for other users.
You could also develop it as a module and open source via NPM.

Dynamically loading tabs designed with Scene Builder

I am building a JavaFX app containing a few static tabs on a TabPane, and during startup will be dynamically adding different tabs with different content as driven by a configuration as needed.
Note, each dynamic tab could be different from each other and I will need to selectively pick which one of these dynamic tabs I want to instantiate/add.
I am using Scene Builder to design the GUI for the bulk of the app. So far everything for the static tabs works fine. Here's where my challenge starts.
How do I leverage Scene Builder to design the dynamic tabs, and only instantiate those tabs as desired at run time as configuration dictates?
Thanks Al
I would put the content of each tab into its own FXML file. You can load the ones that are always loaded in the "main" FXML file, using <fx:include>. Then in the initialize() method of the controller for the main fxml, read the configuration and load the other fxml files you need.
Something like
Main.fxml
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.layout.BorderPane?>
<?import javafx.scene.control.TabPane?>
<BorderPane xmlns:fx="http://javafx.com/fxml" fx:controller="MainController">
<center>
<TabPane fx:id="tabPane">
<Tab>
<fx:include source="StaticContent1.fxml"/>
</Tab>
<Tab>
<fx:include source="StaticContent2.fxml"/>
</Tab>
<!-- etc -->
</TabPane>
</center>
</BorderPane>
and
MainController.java
public class MainController {
#FXML
private TabPane tabPane ;
public void initialize() {
Configuration config = readConfiguration(); // (pseudocode)
if (config.shouldLoadTab1()) {
FXMLLoader loader = new FXMLLoader(getClass().getResource("DynamicTab1.fxml"));
Tab tab = new Tab("Some title");
tab.setContent(loader.load());
tabPane.getTabs().add(tab);
}
// etc
}
}
The FXML files for each of the tabs (whether "static" or "dynamic") would just contain the content of the tab (not the tab pane, which is already defined in the main fxml file, or the tabs, which (the way I have set it up) are defined either in the main FXML or by the controller). So you would just have something like
StaticContent1.fxml
<?xml version=1.0 encoding="UTF-8"?>
<?import javafx.scene.layout.VBox?>
<VBox xmlns:fx="http://javafx.com.fxml">
<!-- nodes... -->
</VBox>
Obviously you can use any layout pane you want in place of the VBox.

Joomla Form Maker where to find html form template

I'm working on Joomla project which is using Form Maker. My task is to improve HTML template but I absolutely can't find it. I've searched everywhere I could in the extension's directory folder.
Structure:
|-models
|----formaker.php
|----index.html
|-uploads
|----index.html
|-views
|----formmaker
|--------tmpl
|------------default.php
|------------default.xml
|------------index.html
|------------main.js
|--------index.html
|--------view.html.php
|----index.html
|-controller.php
|-formmaker.php
|-index.html
|-wd_captcha.php
From my point of view main file is in views/formmaker/tmpl/default.php but I've didn't find the way how I can modify especially the HTML template to change the form params.
Update - Structure of default.xml:
<?xml version="1.0" encoding="utf-8"?>
<metadata>
<layout title="Form">
<message></message>
</layout>
<fields name="request">
<fieldset name="request" addfieldpath="/administrator/components/com_formmaker/models/forms" >
<field name="id" type="modal_contacts" label="Select a Form" required="true"/>
</fieldset>
</fields>
</metadata>
Thank you in advance
According to the Form Maker extension the only possible solution to change the HTML markup of the form elements, it's only to rewriting the whole script for your needs.
Wouldn't recommend to use this script, even Premium version.
Form parametars are in xml file. Try at this path views/formmaker/formmaker.xml

How do I get autocompletion for Flex Metadata?

I took a look at flex metadata and it seems to be quiet straight forward. Though I have a problem, I don't get autocompletion for the metadata.
I'll tell you what I did, maybe you find an error. I want to create my own Style metadata tag named e.g. MyStyle. I want to create my own because it's easier for me to determine at runtime if the metadata was added by me or by the flex framework (therefore I will not use the predefined Style metadata tag).
To add metadata is pretty simple, I just wrote this code to get it work:
<s:Group xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
width="1024" height="768">
<fx:Metadata>
[MyStyle(required="true")]
</fx:Metadata>
</s:Group>
On my WindowedApplication component I added an added to stage listener to the stage. So all elements that are added to the application will fire that Event.ADDED when they are added to the stage. In that eventHandler I scan added elements for my metadata tag.
protected function addedToStageListener(event:Event):void
{
var classInfo:XML = describeType(event.target);
for each (var x:XML in classInfo..metadata)
{
if (x.#name == "MyStyle")
trace(x);
}
}
I also added a flex-config.xml file (in the toplevel of my src folder) to add the compiler options, so that I can read my custom metadata tag on runtime. The file looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<flex-config>
<compiler>
<keep-as3-metadata>
<name>MyStyle</name>
</keep-as3-metadata>
</compiler>
</flex-config>
When I run this, I get the result I expect
<metadata name="MyStyle">
<arg key="required" value="true"/>
</metadata>
So this works. My next step was to add autocompletion when adding the metadata tag to the code. To do this you should create a metadata.xml which specifies the metadata tags right?
So I did this and I ended up with this simple metadata.xml
<?xml version="1.0" encoding="UTF-8"?>
<annotations version="2.1.1">
<metadata name="MyStyle" description="Adds style.">
<context name="class" />
<attribute name="required" type="Boolean" required="true" />
</metadata>
</annotations>
To add the metadata.xml correctly to the project I followed that tutorial by Adobe, but it doesn't work. I don't get autocompletion. Do you have any suggestions?
Update: I use Flash Builder 4.6 Professional and I created a Flex Library Project.