Access one element within another element

Warm greetings,
In the Create Form Activity i have the containers (Cnt1,Cnt2,Cnt3,Cnt4) within that container i have some question (q1,q2,q3…) means each container has 7 questions within that
How to access this q1,q2,q3… that within Cnt1,Cnt2,Cnt3,Cnt4.
Please help me out in this.
Thanks in advance !!

Hello @swathi_sakthi

Will it possible to share a screenshot of the page?

Also use uiexplorer to inspect on the 2 containers and 2 question from each container and share the selector here.

There should some attribute like rownum or idx, which can be used to solve your issue.

Thanks

1 Like

Hello @Rahul_Unnikrishnan sir,


here i have container 1 (Cnt1) within that i have 7 radio component questions.

Jval.Properties.Where(Function(x)x.Name.Contains(“q”)).Sum(Function(x)CDbl(x.Value))

@supermanPunch ,helped me in this part of coding but back then i forgot that questions in create form actitvity comes under the container (which means category).
There are 4 categories, each category carries 7 questions, in total it contains 28 question. Every questions carries 0 or 1 mark according to the options selected by the user.
After the form submitted, i want to add all the marks scored by the user, that could be achieve with the help of above code.
But the questions now available inside the containers . So, if run that process now it shows 0.
I wanna know how to access the questions which inside the container, i tried it but i don’t know where i am wrong .
fl
please help me in this !! :sweat:

Sir, I hope above is understandable. Please let me know, By chance my explanation is not understandable.

Hi @swathi_sakthi ,

Assuming that these are the Filed Keys of the containers, we can use the below Expression to calculate the Sum from the Different Questions obtained.

Jval("Cnt1").ToObject(Of JObject).Properties.Where(Function(x)x.Name.Contains("q")).Sum(Function(x)CDbl(x.Value))

The above should give you the total marks of the First Container.

Let us know if you are not able to understand the above and let us know if you get any error.

1 Like

Thank you so much sir :dizzy:, it is working
Is it possible to wrote code to sum up all the marks of the question inside the container component in one go sir?

@swathi_sakthi ,

Do you mean you want to Sum up all the marks from all containers ?

1 Like

yes sir, that what i mean…

i did a work flow like assigning this code
Jval("Cnt1").ToObject(Of JObject).Properties.Where(Function(x)x.Name.Contains("q")).Sum(Function(x)CDbl(x.Value))
to a double var for container 1 and like wise for all containers…
and adding all that variable then assigning that to another double variable
fff
Like this sir…

@swathi_sakthi ,

Yes. This is one method that we could use, as we would also need each Container’s total value.

For receiving at one go, Maybe this is what you were looking for :

Jval.Properties.Where(Function(x)x.Name.Contains("Cnt")).Children.SelectMany(Function(x)x).Cast(Of JProperty).Sum(Function(x)CDbl(x.value))

Let us know if this gives out any errors.

1 Like

Sir,
It’s throwing some error.It worked back then, I don’t know now it’s not working

err

RemoteException wrapping System.FormatException: Input string was not in a correct format.
at System.Number.ThrowOverflowOrFormatException(ParsingStatus status, TypeCode type) at System.String.System.IConvertible.ToDouble(IFormatProvider provider) at System.Convert.ToDouble(Object value, IFormatProvider provider) at Newtonsoft.Json.Linq.JToken.op_Explicit(JToken value) at Namespace_6ed8.Main_Expressions.Main_Expressions_TypedDataContext2_ForReadOnly._Closure$__._Lambda$__17-2(JProperty x) at System.Linq.Enumerable.Sum[TSource](IEnumerable1 source, Func2 selector) at Namespace_6ed8.Main_Expressions.Main_Expressions_TypedDataContext2_ForReadOnly.__Expr3Get() at Namespace_6ed8.Main_Expressions.Main_Expressions_TypedDataContext2_ForReadOnly.ValueType___Expr3Get() at Namespace_6ed8.Main_Expressions.InvokeExpression(Int32 expressionId, IList1 locations, ActivityContext activityContext) at System.Activities.Expressions.CompiledExpressionInvoker.InvokeExpression(ActivityContext activityContext) at Microsoft.VisualBasic.Activities.VisualBasicValue1.Execute(CodeActivityContext context) at System.Activities.CodeActivity1.InternalExecuteInResolutionContext(CodeActivityContext context) at System.Activities.Runtime.ActivityExecutor.ExecuteInResolutionContext[T](ActivityInstance parentInstance, Activity1 expressionActivity) at System.Activities.InArgument1.TryPopulateValue(LocationEnvironment targetEnvironment, ActivityInstance activityInstance, ActivityExecutor executor) at System.Activities.RuntimeArgument.TryPopulateValue(LocationEnvironment targetEnvironment, ActivityInstance targetActivityInstance, ActivityExecutor executor, Object argumentValueOverride, Location resultLocation, Boolean skipFastPath) at System.Activities.ActivityInstance.InternalTryPopulateArgumentValueOrScheduleExpression(RuntimeArgument argument, Int32 nextArgumentIndex, ActivityExecutor executor, IDictionary2 argumentValueOverrides, Location resultLocation, Boolean isDynamicUpdate) at System.Activities.ActivityInstance.ResolveArguments(ActivityExecutor executor, IDictionary`2 argumentValueOverrides, Location resultLocation, Int32 startIndex) at System.Activities.Runtime.ActivityExecutor.ExecuteActivityWorkItem.ExecuteBody(ActivityExecutor executor, BookmarkManager bookmarkManager, Location resultLocation)
e

@swathi_sakthi ,

Was the Form Submitted or was the Form Closed ?, Try to Check the value of Jval when Debugging if it is still not working.

1 Like

Sir, i think i missed out to answer a question in form. Is that a reason for this error?
Now it’s working correctly

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.