How to pass variable form aura component to screen flow - salesforce

Question :
i implemented screen flow to update case object and here i tried to invoke flow from aura component
flow invoking as expected but i want pass case id from aura controller to screen flow
how can we pass variable from aura to flow ?
thank you !

The method startFlow takes two parameters:
flowName - Required. The unique name of the flow.
inputVariables - Optional. An array of object used to set the initial values for the flow’s input variables.
In your controller you should have something like this:
init : function (cmp) {
var flow = cmp.find("myFlow");
var inputVariables = [
{
name : 'CaseId',
type : 'String',
value : cmp.get("v.caseId")
}
];
flow.startFlow("myFlowName", inputVariables);
}
You could take a look at flow component documentation.

Related

Add nested property in Redux reducer

I've been a few days trying to get my head around Redux to be used with my Reactjs project. I'm working on a reducer and trying to add a nested property into state. To do this, I'm using spread operator at different levels. The problem is that initially the state slice this reducer manages is empty and therefore I run into the following problem... taking this as an example of what I'm trying to do:
var foo = {}; // Initially the state slice is an empty object.
var bar = {...foo,
1: {
...foo[1],
2: {
...foo[1][2],
baz: 100 // New property I'm trying to add.
}
}
};
console.log(bar);
(property keys 1 and 2 are two variables provided to the reducer in my actual app)
I you run the above piece of code it will yield en error saying Cannot read property '2' of undefined at line ...foo[1][2],. Alright, foo[1][2] is not defined yet, but how am I supposed to accomplish this? Maybe I'm missing something very basic...
something like that works for your example but it seems pretty hacky.
bar = {
...foo,
1: {
...foo[1] ? foo[1] : {},
2: {
...foo[1] && foo[1][2] ? foo[1][2] : {},
baz: 100 // New property I'm trying to add.
}
}
}

How to reset data of all the states : angularJs UI router

.state('state1'
{
name :
url:
data:{
data1=[];
data2=[];
}
});
.state('state2'
{
name :
url:
data:{
data1=[];
data2=[];
}
});
Let us say I have n number of states.When user goes from one state to another
he is storing data into $state.current.data.
My question is , "is there any shortcut or any technique to reset the data for all the states again", let us say for the scenario when user logs out from the application , I want to reset the data .
I don't want to use $window.location.reload()
Any suggestions/help is appreciated!!
Thanks
You can use $state.get() to get all the configured states and then reinitialize the data object to a desired value.
Important: child states inherit the data property from their parent states - source. In order not to break the inheritance we'll use angular.copy.
This example reinitializes the data object with {}
angular.forEach($state.get(), function (state) {
angular.copy({}, state.data);
});
Note that there isn't any way to know the original value of the data object without explicitly specifying or storing it.

Pass parameter to tab

I am building my first Angular app with a list of product specifications such as "Brand name" etc. The finished app will be connected to an MSSQL db.
I have a list with the saved Specifications and when I click one of them I want the following to happen:
Show Edit Specification Tab
Pass the parameter SpecificationId
Perform an http GET with current Specification Id
I set up a plunker with the app in its basic state:
http://embed.plnkr.co/4F8LMwMorZEF0a42SzTJ/
As you are already sending your id you just need to get it within your method:
Update your controller like this:
app.controller('TabController', function ($scope) { // use $scope here
and set the id in the $scope.spec object like below:
this.setTab = function (selectedTab, specId) { // get the id in the args here
this.tab = selectedTab;
$scope.spec = {id : specId}; // set the id in here
console.log($scope.spec.id);
};
and then you can bind the id value in the markup as this:
The current Specification ID is: <strong>{{spec.id}}</strong>
Updated plunkr demo.

short names for extjs classes and namespaces

i have something like
Ext.define('HS.controller.Utility', {
statics : {
state : 'Oklahoma'
}
});
Now i want to access it from my controllers, but in every method of controller, i have to write HS.controller.Utility.state to access it. currently i'm doing this : var ut = HS.controller.Utility and then accessing state as ut.state, but again, i've to declare this variable in every function. Is there a way to set it to a short name once in my controller and then access from all functions?
There are several ways you could do it, the best of which:
// Becomes a global variable
var X = Ext.define('My.long.class.Name');
// Set a reference on your main NS at launch time
launch: function() {
MyApp.X = My.long.class.Name;
}
Even easier than the current answer is to just declare an alternateClassName with no namespace. Only one line of code, no initialization or race conditions, built into ExtJs.
Ext.define('HS.controller.Utility', {
//
// Non-namespaced alternate class name will create
// 'globally defined' Utility object.
//
alternateClassName: 'Utility',
statics : {
state : 'Oklahoma'
}
});
});

How to serialize form inside modal window in ExtJS?

I'm trying to build modal windows on the fly from single javascript object passed by server.
But I have no clue how can I serialize form inside modal window without defining form variable .
In most examples serialize process look like this:
//create form
var CustomForm = new Ext.FormPanel({...});
//submiting form
CustomForm.getForm().submit({...});
In my case all inner components like "form" are created from xtype value,and no variable is assigned to it.
Is there any way to select and serialize form using something like this:
Ext.get(this).select('form').serialize();
or what is apropriate way of doing so?
You can assign the form an id and use Ext.getCmp(formid).
To retrieve the form values of a FormPanel use myFormPanel.getForm().getValues()
That will come back with a js object representing the form fields.
I wrote a function to take values from a form and generate a string for adding to the query string:
/**
* takes an array of form values and converts them into a
* query string
*
* #param {object} Ext.form
* #return {string}
*/
this.serialize_form_values = function(form)
{
var serial = '',
values = form.getValues();
for(var value in values)
serial += '&' + value + '=' + values[value];
return serial.substr(1);
};
Maybe it could be useful for someone?

Resources