Hi , I am trying to pass one variable value form CamSDK.Form and trying to get this in html form. Any body having idea reply me as soon as possible.
Hi maheshkunta,
sorry but the formulation of your question is a bit odd.
Have you looked at the embedded forms documentation?
Hi @maheshkunta,
Could you please elaborate what you mean with “… pass one variable value from CamSDK.Form…”? What do you want to achieve? What is your use case?
Cheers,
Roman
I have to add one variable value as var in new CamSDK.Form({
client: camClient,
formUrl: url,
var: var,
taskId: $scope.selectedTask.id,
containerElement: $formContainer,
// continue the logic with the callback
done: submitForm
});
so that i can retrive this value from html form as
camForm.on(‘variables-fetched’, function() {
var variableValue = variableManager.variableValue(‘var’);
Hi @maheshkunta,
Why do you want to add a variable to the CamSDK.Form
? Is it not possible for you to create a variable like described here 1? This would look like this for example:
camForm.variableManager.createVariable({...});
Cheers,
Roman
HI,
I had created variable in script.js file like
variableManager.createVariable({
name: ‘customVariable’,
type: ‘String’,
value: ‘Some Value…’,
isDirty: true
});
After this i tried to get the value from html like below
camForm.on(‘variables-fetched’, function() {
// this callback is executed after the variables have been fetched from the server
var variableValue = variableManager.variableValue(‘customVariable’);
$( ‘#my-container’, camForm.formElement).textContent(variableValue);
});
But i didn’t got the variable value.
Please try this:
camForm.on('variables-fetched', function() {
camForm.variableManager.createVariable({
name: 'customVariable',
type: 'String',
value: 'Some Value...',
isDirty: true
});
var variableValue = camForm.variableManager.variableValue('customVariable');
$( '#my-container', camForm.formElement).textContent(variableValue);
});
Cheers,
Roman
yes i had tried this approach by placing the below code in script.js
camForm.on(‘variables-fetched’, function() {
camForm.variableManager.createVariable({
name: ‘customVariable’,
type: ‘String’,
value: ‘Some Value…’,
isDirty: true
});
the following code in html
var variableValue = camForm.variableManager.variableValue(‘customVariable’);
$( ‘#my-container’, camForm.formElement).textContent(variableValue);
and also the total code in html form but i am unable to get the variable value in html.
Hi @maheshkunta,
Could you please try this
camForm.on('variables-fetched', function() {
camForm.variableManager.createVariable({
name: 'customVariable',
type: 'String',
value: 'Some Value...',
isDirty: true
});
var variableValue = camForm.variableManager.variableValue('customVariable');
if (variableValue) {
alert(variableValue);
}
$('#my-container', camForm.formElement).text(variableValue);
});
I changed the following parts:
- I added an alert, which will pop up when the variable is available
- instead of
textContent()
I usetext()
So, at least you should get an alert.
Cheers,
Roman
In addition, maybe you could share your sources?
Hi,
I tried this approach in html but i didn’t get any alert value.
Hi @maheshkunta,
I tested the provided code in an embedded form inside task list and it worked for me.
Please share your sources.
Cheers,
Roman