am Using Apex4.1,
in my application I have one Tabular form which has the following fields,
Emp_id
Emp_name
Dept_id
Here Emp_id is the Updatable column and it is a select list LOV and
Emp_name is a upadatable column,
Here what I need is,
If I select the Emp_id from the LOV ,the Emp_Name should be stored automatically based
on the value selected in EMP_ID,
In tabular form I could not create Dynamic action like creating in normal forms,
Can anyone help me in this issue?
Thank you.
APEX does not currently provide dynamic actions on tabular form items. Hopefully this may be addressed in APEX 4.2 but the Statement of Direction does not explicitly say so.
So for now if you need to do this you will have to write your own Javascript, using the unique IDs of the tabular form items to manipulate them (the IDs look like "fcc_rrrr" where "cc" is the column number and "rrrr" is the row number). See this SO q&q for sample Javascript code that uses these.
The Javascript you need to write is a little daunting (for a beginner), but one thing to note is that in your case you can avoid any need for using AJAX to get the employee name by embedding the name in the return value of the LOV something like this:
select emp_name d, emp_id||':'||emp_name r
from employee
order by 1
This way the return values will look like '123:John Smith'; your Javascript can parse this string and extract 'John Smith' and insert it into the emp_name item on the same row. Obviously you will also need to parse this string to obtain the emp_id value you will need when updating the database when the page is submitted.
Related
I show a model of sales that can be aggregated by different fields through a form. Products, clients, categories, etc.
view_by_choice = filter_opts.cleaned_data["view_by_choice"]
sales = sales.values(view_by_choice).annotate(........).order_by(......)
In the same form I have a string input where the user can filter the results. By "product code" for example.
input_code = filter_opts.cleaned_data["filter_code"]
sales = sales.filter(prod_code__icontains=input_code)
What I want to do is filter the queryset "sales" by the input_code, defining the field dynamically from the view_by_choice variable.
Something like:
sales = sales.filter(VARIABLE__icontains=input_code)
Is it possible to do this? Thanks in advance.
You can make use of dictionary unpacking [PEP-448] here:
sales = sales.filter(
**{'{}__icontains'.format(view_by_choice): input_code}
)
Given that view_by_choice for example contains 'foo', we thus first make a dictionary { 'foo__icontains': input_code }, and then we unpack that as named parameter with the two consecutive asterisks (**).
That being said, I strongly advice you to do some validation on the view_by_choice: ensure that the number of valid options is limited. Otherwise a user might inject malicious field names, lookups, etc. to exploit data from your database that should remain hidden.
For example if you model has a ForeignKey named owner to the User model, he/she could use owner__email, and thus start trying to find out what emails are in the database by generating a large number of queries and each time looking what values that query returned.
I am pretty new to python/django, but previously programmed in C# and VB.Net. I need to create a list on my django form that contains data elements from a PGSQL table. The user should be able to select multiple rows and then I would formulate a query that I would send back to the server. I have researched, but have not found anything to point me in the right direction. I will show my code below.
forms.py
PROD_MULTI_RECORDS=[
('darryl.dillman','darryl.dillman'),
('richard.mcgarry','richard.mcgarry'),
('janet.delage','janet.delage')
]
class rdsprodform(forms.Form):
selectmulti =
forms.CharField(widget=forms.SelectMultiple(choices=PROD_MULTI_RECORDS),
required = False, label = "Please select records to process")
So I am pretty new to Sitecore, and I seem to have gotten myself into an issue that I cant solve or google ;)
So I have an item, this Item has a treelist, and that treelist has a datasource "Products". Now this works fine, the issue is that I only want the items (products) displayed in my treelist, where the Product Category is "Shoes".
The Product template has a Multilist named "Categories", so i would like a query, that evaluated if one of the Categories is "Shoes" if so, include the Product in my Treelist, if not exclude it.
Can it be done with a query or do I need to do some actual code to get that result?
Any help would be much appriciated.
You can use Sitecore's fast query in source field of template field as below:
Using contains:
fast:/sitecore/content/Home/Products//*[contains(#Categories = 'IdOfShoesItem')]
Using like:
fast:/sitecore/content/Home/Products//*[#Categories = '%IdOfShoesItem%']
On older sitecore version fast query does not work, in those cases replace "fast" with "query" like below:
query:/sitecore/content/Home/Products//*[#Categories = '%IdOfShoesItem%']
I am developing a mobile application that should allow a student to search for job vacancies. I have used the wizard to create a form with a list view. The list view will only show job titles which are not past their closing date (available jobs)
When a job title is clicked it redirects to the form where the student can view further job details. These values are passed automatically by the wizard.
Now while this whole thing is great I need information from 3 different tables and the wizard won't help me with that.
I have created a list view based on an sql query and also a form based on an sql query. I have tried to create automatic fetch processes to pass the values from my list view to the form view but nothing I have tried has worked. I carefully analysed the forms created by the wizard to see how it could be done but nothing worked for me and I would really love to do it in this way.
For reference this is the sql code I used for the list view (and it's the same for the form view except for the where clause )
T1.JOB_TITLE,
T1.SALARY,
T1.JOB_DESCRIPTION,
T1.START_DATE,
T1.CLOSING_DATE,
T1.METHOD_ID,
T3.METHOD_NAME,
T1.SITE_ID,
T2.CITY,
T2.ADDRESS_FIRST_LINE,
T2.EMAIL,
T2.COMPANY_NAME
FROM JOB T1
JOIN SITE T2 ON (T2.SITE_ID = T1.SITE_ID)
JOIN APPLICATION_METHOD T3 ON (T3.METHOD_ID = T1.METHOD_ID)
Where (T1.Closing_Date >(Select Current_Date from dual))
There are really two ways you could solve this:
1) If you can simply pass the values you need to the form page, edit the values of your Form region, and open up the "Link Target" attribute (this is assuming you're using APEX 5 Page Designer). There, you will be able to pass in multiple values to items on your Form page.
2) If, instead, you need to derive these values on your Form page, add an After Header process on your form page and do the lookups from your other tables in this process, using PL/SQL. You can use the bind variable syntax to reference your items and update session state. For example:
begin
for c1 in (select val1, val2 from my_other_table where id = :P3_ID) loop
:P3_ITEM1 := c1.val1;
:P3_ITEM2 := c1.val2;
exit;
end loop;
end;
I managed to add the additional columns by adding more items and selecting an Sql-query that returns a single row from the item attributes (Source).
So in order to get method_name rather than an ID which would be irrelevant for the end user I used this code:
SELECT METHOD_NAME FROM APPLICATION_METHOD
WHERE (METHOD_ID = :P3_METHOD_ID)
I am fairly certain that it might not be a great solution if you have a lot of columns that need to go through but it was easy to understand and implement for a few additional columns.
I'm trying to make a poll results page with the results from a WFFM form. I initially took all the entered data(using AnalyticsFormsDataProvider), queried it, and then displayed the results. However, if no one votes for a particular answer, it wouldn't be in the entered data so it wouldn't show.
I want to display that the field had 0 votes, so now I'm trying to compare the possible answers to the queried list. However, I can't seem to find a way to access the values of the list items. Does anyone know the class those values are stored in and/or how to access them?
I'm using WFFM 8.1 rev. 151217 (Update-1) with MVC. It's a radio list field if that makes a difference from the other list fields.
Thanks,
You are able to get WFFM field as regular Sitecore item via standard API.
Available list items values are saved in "Parameters" and "Localized Parameters" fields. You can use Sitecore.Form.Core.Utility.ParametersUtil from Sitecore.Forms.Core to parse values saved in these fields.
This data is stored on your Radio List Field's Item in the fields Parameters and Localized Parameters.
If your code is within the Form's SaveAction or a Validator you will have access to the Field in the for AdaptedResultList args the SaveAction or via this.classAttributes["fieldid"] for the Validator. That will be enough for you to get the Radio List Item and then the Parameter fields.
If your code is not in a SaveAction / Validator I recommend passing the Form Item into your code possibly by Datasource and then retrieving the Radio List Item from that.
Finally the Items of the your Radio List field is stored in the format
<item><item>
If your radio items are actually items you will want to parse them using a regex
var regexItems = new Regex(#"<item>(.*?)</item>".ToLower());
var itemNodes = regexItems.Matches(FieldItem["Parameters"].ToLower());
Then you should be free to play with the list for your poll