Moqui ::: How to edit list using section iterator - moqui

We are trying to display data in a form-list field using section-iterate. Data is being displayed correctly. However, once updating fields, the list used in the section-iterator is not being updated.
Sample code:
<form-single name=“editTest”  transition=“editOneTest”>
<auto-fields-entity entity-name="test.Test” field-type="edit"/>
<field name="testDetails"><default-field>
<section-iterate name="TestDetailSection" list="testDetailList" entry="testDetail" >
        <condition>
            <compare field="testDetail.testId" operator="equals" to-field="testId"/>
        </condition>
        <widgets>
            <field name="hours">
                <default-field>
                    <text-find default-operator="equals" hide-options="true" default-value="${testDetail.hours}" size="5" />
                </default-field>
            </field>
        </widgets>
    </section-iterate>
</default-field></field>
</form-single>
Notes:
We tried to declare list like and add the hours edited in the new list. It didn't work.
I tried to create a script inside of section-iterate to edit the testDetailList and didn't work.
Kindly, assit us to solve this issue.

Make sure you have the XSD (xml-screen-.xsd in this case) specified in your screen XML file and that your editor is validating the XML. The XML you've mentioned here is not valid.
The 'field' element cannot contain another field element, and a field element can't go under the 'widgets' element (it can only go under a default-field, conditional-field, or header-field element).
If you look at the HTML generated you'll see it has issues as the macros to transform XML to HTML do not support this sort of thing.

Related

How can I get any/all the Dataverse table relationship behavior and actions? through SQL query or any export mechanism

In dataverse table relations, I wants to get all the relationship behavioral types for all the table relations.
In the above image, I had shown the one relationship behavioral actions and I wanted to query (SQL query) or any export mechanism to get the entire relationship behavioral actions(specially delete action) for contact table. is it possible to get?
ex.
name
relationship type
type
 action
 behavior
contact_customer_accounts
         Many-to-one
         Parential
           delete
        cascade all
contact_customer_contacts
         Many-to-one
        System
              delete
       Remove Link

Structuring looker Explore Results

I’m having trouble figuring out how to count publications in my Looker data set by year and author. In my Looker explore the data Looker table results look like this:
Pub_id
year
author
author_id
1_1
2021
john
5.5
1_2
2020
john
5.5
  1_3 
2021
jane
2.0     
  1_4 
2021
jane
2.0     
  1_5 
2019
garth
3.6     
  1_6 
2013
wayne
1.7     
I want to create a bar chart that gives me the total number of publications per year, so:
                                           x
                                           x
  x             x          x            x
2013    2019    2020     2021
My struggle is getting the count or aggregate of the count correct.
I’m also trying to crate an aggregate count by authors, so output would look like:
Author
Number of publications
John  
         2           
Jane 
         2           
Wayne 
         1           
Garth 
         1           
Thanks for help or advice!
Both of these aggregations should use a single dimension and a single measure. For both, the measure should be a simple count:
view: my_view {
measure: number_of_publications {
type: count
}
}
Then in the explore, you should only select this measure and a single dimension (year for the first one and Author for the second), and you'll end up with a table like the one you posted above for Author.
Once you have the table, just select the bar chart type and you should be good to go.

How do I calculate how many times something occurs in a 7 day period?

I have an Excel sheet of 1 million rows that span 12 months from January 2020-January 2021. I have to display all of the attributes for the output.
This is an example of the 2 attributes I'm looking at for the code, but there are 15 attributes in total:
Attribute: Subscriber_Number |   Date_Email_Sent 
19202                     03Dec2020
12829                     03Dec2020 
13455                    05Dec2020
13455                    05Dec2020
13455                   02 Dec2020
13455                   04 Dec2020
An email cannot be sent to a subscriber more than 3 times a week. If that happens, that would become an issue. My goal is to find subscribers who have been called more than 3 times a week. In the example data I gave, the code output should show that Subscriber 13455 was called 4 times in a week. The code output should NOT include 12829 because it just occurs one time. 
This is a code that I tried:  
PROC SQL;
Select week (Date_Email_Sent, 'u') as weeknum, COUNT(Subscriber_Number) as per_week FROM Data;
Where SubscriberNumber >2
Group By week(Date_Email_Sent, 'U')
quit;
I got a large results were detected line, so I discarded results. There shouldn't be that many times that an email was sent to a subscriber (<10,000 instances), so I'm sure that I wrote the code incorrectly.
With standard sql, you can find those records using:
select Subscriber_Number, Date_Email_Sent
from Data
group by Subscriber_Number, Date_Email_Sent
having count(*) > 3
If you want subscribers who received more than 3 emails in a calendar week, then the logic should look like this:
PROC SQL;
Select week(Date_Email_Sent, 'u') as weeknum, Subscriber_Number,
count(*) as per_week
from Data;
Where SubscriberNumber >2
Group By week(Date_Email_Sent, 'U'), Subscriber_Number
having count(*) > 3;
quit;

How to format SQL subquery to produce new and old data

I have a database where I am trying to figure out this problem. I want to write a SQL query to list all patients whose information has changed during their future visits. A future visit is defined as dbo.patientvisit.encounter_id < dbo.visitvitalstat.encounter_id The outputs I want in the table are the columns patient number, old and new race values, old and new gender values, and both encounter ids from the both tables. The new race and gender values are from future visits.
This is the code I have so far but I can't figure out how to get the new gender and new race values.
SELECT pv.patient_nbr,pv.encounter_id, vvs.race, vvs.gender, vvs.encounter_id
FROM PatientVisit pv
LEFT JOIN VisitVitalStat vvs
ON pv.encounter_id = vvs.encounter_id
WHERE pv.encounter_id < vvs.encounter_id;
This is the result I should get back:
SELECT  fpv.patient_nbr(??)
                vvs.race as "Old race",
                fv.newrace as "New Race",
                vvs.gender as "Old Gender",
                fv.newgender as " New Gender",
                vvs.encounter_id as "Old Encounter ID" ,
                fv.newencounter as "New Encounter ID"
FROM  VisitVitalStat vvs
INNER JOIN
                    ( SELECT fpv.patient_nbr as newnbr,
                                      fvvs.race as newrace,
                                      fvvs.gender as newgender,
                                      fvvs.encounter_id as newencounter
FROM PatientVisit fpv, VisitVitalStat fvvs
                      WHERE  fpv.encounter_id = fvvs.encounter_id
                              AND
                                      fpv.encounter_id < fvvs.encounter_id) fv
ON   fv.newencounter = vvs.encounter_id;
So I was able to write a query but I feel like it is still off, I'm not sure how to get patient number into all of this.
One method uses lag():
select pv.*
from (select pv.*,
lag(gender) over (partition by patient_nbr order by encounter) as prev_gender,
lag(race) over (partition by patient_nbr order by encounter) as prev_race,
lag(encounter) over (partition by patient_nbr order by encounter) as prev_encounter
from patientvisit pv
) pv
where prev_gender <> gender or prev_race <> race;
You can adapt this solution. Where b1 will be the old data and b2 the new data.
with base as (
select
patient_nbr
,encounter_id
,row_number() over (partition by patient_nbr order by encounter_id asc) as row
from patientvisit
LEFT JOIN VisitVitalStat vvs
ON pv.encounter_id = vvs.encounter_id
)
select b1.patient_nbr
,b1.encounter_id as old
,b2.encounter_id as new
,b1.gender as old
,b2.gender as new
,b1.race as old
,b2.race as new
from base b1
join base b2 on
b1.patient_nbr=b2.patient_nbr
and b1.row+1=b2.row

Msg 207, Level 16, State 1, Line 1 Invalid column name 'ItemTotal' [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 1 year ago.
Improve this question
I wrote this code. It works fine without my WHERE Statement. I keep getting an error
Msg 207, Level 16, State 1, Line 1 Invalid column name 'ItemTotal'.
I don't know what I did wrong!
SELECT    
    ItemID, 
    ItemPrice,    
    ItemPrice * quantity AS PriceTotal,
    DiscountAmount * quantity AS DiscountTotal,
    ((ItemPrice - DiscountAmount) * quantity) AS ItemTotal
FROM                                                                                                                                                               
    OrderItems
WHERE ItemTotal > 500;
No database platform was given, but based on the query: 'ItemTotal' is not a column you can use, as it's an alias. You need to filter on the actual data
SELECT
ItemID,
ItemPrice,
ItemPrice * quantity AS PriceTotal,
DiscountAmount * quantity AS DiscountTotal,
((ItemPrice - DiscountAmount) * quantity) AS ItemTotal
FROM
OrderItems
WHERE ((ItemPrice - DiscountAmount) * quantity) > 500;