Global function works in preview but fails when code is run - anypoint-studio

I have a global function named 'finalPrice' which is defined in my configuration.xml file.
The function takes in a value - does stuff to it - and returns the final value. I reference the function from within DataWeave. When I click 'preview' I can see the correct output in the preview window. However when I run it I get the error:
Message : Exception while executing:
There is no variable named 'finalPrice'.
I have run the code on my local machine and in CloudHub and I get the same result
XML Code:
<configuration doc:name="Configuration">
<expression-language>
<global-functions>
<!-- This function is called by the 'Validate and Transform' dataweave component in the 'main' flow-->
def finalPrice(incoming_value)
{
import java.lang.String;
import java.math.RoundingMode;
// Do Stuff
return strFinalNumber;
}
</global-functions>
</expression-language>
</configuration>
DataWeave Code:
//Refer to "finalPrice" Global Function in the main.xml configuration file
DB_FINL_PRCE: "field_missing" when payload01.DB_FINL_PRCE == "" otherwise finalPrice(payload01.DB_FINL_PRCE)
Any help appreciated

It's an issue with the comments in the global-functions. So remove or modify the line:
<!-- This function is called by the 'Validate and Transform' dataweave component in the 'main' flow-->
and just have:
<configuration doc:name="Configuration">
<expression-language>
<global-functions>
def finalPrice(incoming_value)
{
import java.lang.String;
import java.math.RoundingMode;
// Do Stuff
return strFinalNumber;
}
</global-functions>
</expression-language>
</configuration>
Or modify your comments to //
<configuration doc:name="Configuration">
<expression-language autoResolveVariables="true">
<global-functions>
//This function is called by the 'Validate and Transform' dataweave component in the 'main' flow
def finalPrice(incoming_value)
{
// Do Stuff
return "somethingelse";
}
</global-functions>
</expression-language>
</configuration>

Related

Failed to instantiate file "app.module.ts" from module "RootModule"

I have sharepoint add-in project, I have inculuded necessary angular2 packages and ts files as you see ss of solution explorer in below:
and here is my ts file contents;
boot.ts
import {bootstrap} from 'angular2/platform/browser';
import {AppComponent} from './app.component';
bootstrap(AppComponent)
app.component.ts
import {Welcome} from './app.module';
import {Component} from 'angular2/core';
#Component({
selector: 'app-main',
template:'<h1>${Welcome.getMessage()}</h1>'
})
export class AppComponent {}
app.module.ts
export class Welcome {
static getMessage() {
return "Hello World!";
}
}
when I run this application I always get this error message in output window:
> #"Error 1
> CorrelationId: ae2bcaba-cdac-4178-bd39-2aca278a2e31
> ErrorDetail: There was a problem with activating the app web definition.
> ErrorType: App
> ErrorTypeName: App Related
> ExceptionMessage: Failed to instantiate file "app.module.ts" from module "RootModule": Source path
> "Features\SharePointAddIn4_Feature1\app.module.ts" not found.
> Source: AppWeb
> SourceName: App Web Deployment
I have search but cant find any solution helped me.. any idea how to fix this?
To resolve this, I had to set the tsconfig.json file (and others) to not deploy, and remove it from Elements.xml in the root of the project.
<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<Module Name="RootModule">
</Module>
</Elements>
Hey Buddy there are few points to be clear here before answer
you are using too old version of angular2 may be you are in angular2 beta
(as you are using 'angular2/core' now it is '#angular/*')
you are using wrong syntax according to me
{Welcome.getMessage()}
there are syntax like this
{{Welcome.getMessage()}}
also you are trying to access class Welcome without even initializing in the constructor of app.component.ts file, which is wrong .

Import nested Typescript module

I have got the type definition file for a library - seneca. I don't know know how to import this module into typescript source.
I have used
/// <reference path="../custom_typings/seneca.d.ts" />
Please see the below seneca.d.ts file
I want to use the add(..) function in the seneca module.
Just add it to the module s e.g.
module s {
export var add:Function; // Sample

Alfresco custom aikau footer

I want to customize Alfresco aikau footer. For the beginning I would like to inject custom html-template in AlfShareFooter. So far I created an extension:
<extension>
<modules>
<module>
<id>MyCmpny widgets</id>
<version>1.0</version>
<auto-deploy>true</auto-deploy>
<configurations>
<config evaluator="string-compare" condition="WebFramework" replace="false">
<web-framework>
<dojo-pages>
<packages>
<package name="mycmpny" location="js/mycmpny"/>
</packages>
</dojo-pages>
</web-framework>
</config>
</configurations>
</module>
</modules>
</extension>
Html template for the footer and now I'm trying to override templateString of the AlfShareFooter object:
define(["dojo/_base/declare",
"alfresco/footer/AlfShareFooter'",
"dojo/text!./templates/ep-footer.html"],
function (declare, AlfShareFooter, template) {
return declare([AlfShareFooter], {
templateString: template
})
});
But it doesn't work. I am not familiar with Dojo and I think the problem is in the syntax...
I've found out how to override template:
define(["dojo/_base/declare",
"dojo/text!./templates/my-footer.html",
"alfresco/footer/AlfShareFooter"],
function (declare, template, AlfShareFooter) {
return declare([AlfShareFooter],{
postMixInProperties: function my_footer_AlfShareFooter__postMixInProperties(){
this.inherited(arguments);
this.templateString = template;
}
});
});
But with g̶r̶e̶a̶t̶ custom footer template comes g̶r̶e̶a̶t̶ custom css and i18n... So I wrote a post about changing Aikau footer in Alfresco.

Ecma Error: TypeError: Cannot call property

I have written some java code in an adapter in worklight project. when i m trying to call the java method, i am getting an error saying
"responseID":"6","errors": {Ecma Error: TypeError: Cannot call property downloadFile in object
JavaPackage java.classes.FileIOPlugin]. It is not a function, it is
\"object\".}
I have followed the procedure exactly stated in the following link.
Using Java in Adapters
this is my project structure. Is there something wrong with this structure or should i add anything more to this?
This is how i am trying to call the java non-static method in adapter-impl.js
function downloadFile() {
var fileInstance = new com.worklight.JavaCode.FileIOPlugin();
return
{ result: fileInstance.downloadFile(); };
}
We have identified another possible solution to this.
Change Java compiler level to 1.6 as well as default JRE to 1.6:
Make sure your package starts with com, e.g. rename it to "com.classes".
Try adding the parenthesis when you instantiate your object:
var fileInstance = new com.worklight.JavaCode.FileIOPlugin()
Check your .project file and make sure it has the right buildCommand tags in it.
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.wst.jsdt.core.javascriptValidator</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.wst.common.project.facet.core.builder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>com.worklight.studio.plugin.WorklightProjectBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.wst.validation.validationbuilder</name>
<arguments>
</arguments>
</buildCommand>
Read more at: ECMA TypeError calling Java class from Worklight adapter

How do I write html to magento footer in a module

I am trying to make a basic Magento module that writes to the footer of a store.
Here's what I've got so far.
<?php
class CTRL_DRP_Block_Footer_Footer extends Mage_Page_Block_Html_Footer{
protected function _toHtml(){
$html = 'CPTEST';
return $html;
}
}
I'm not sure if I'm heading in the right direction here. Can someone send me resources to help me learn how to go about this correctly?
Any help is appreciated.
The footer block already exists so you only need to add a simple block inside it.
In your module's config.xml file define a layout file.
...
<frontend>
<layout>
<updates>
<YOUR_MODULE>
<file>YOURMODULE.xml</file>
</YOUR_MODULE>
</updates>
</layout>
</frontend>
...
In the base theme's layout/YOURMODULE.xml file add to the footer block.
...
<default>
<reference name="footer">
<block type="core/template" name="YOUR_MODULE_footer" template="YOURMODULE/footer.phtml" />
</reference>
</default>
...
Create the appropriate template/YOURMODULE/footer.phtml file for the same theme.
<p>CPTEST</p>