Say I have an entity Customer which has relationship with city, order etc. Now when I am adding a customer object, should I assign customer.cityid, or customer.city? From the form I get cityid from a dropdown, so to assign the city object, I will have to make a query using id selected.
If you need the City object populated, then get the City and set .City.
If you don't need the City object and are just saving and moving on, setting .CityId without getting the city object will save you the select query fetching it.
In either case, the next time the object loads, City will be available. (Both methods save the same City column in the database unless you have something strange/non-default setup).
Related
I have following ONE dataset with additional columns not mentioned for ease of reading,
Address1_PostCode Address2_PostCode
Address1_Line1 Address2_Line1
Address1_Line2 Address2_Line2
Address1_Country Address2_Country
Desired output is,
Address2_PostCode
Address2_Line1
Address2_Line2
Address2_Country
Here is what I am trying to do,
If any of Address1 field has data then overwrite Address2 fields, e.g. if Address1 only has postcode and Address2 has Country, the final result will have only postcode and country will be empty or null
If all fields of Address1 are empty then don't do anything
I already searched on my own and I can see there is functionalities like replace column to add new and replacenull function, but I am not able to understand them enough to achieve my goals
Add a Derived Column transformation that has a new column expression with a boolean result that will check whether all Address1 fields are empty/null or not.
Add another Derived Column transformation after that one (unless you want to repeat the validation expression on each column) that checks for this bool result and reassigns the proper field from either Address1 or Address2, on each field you need.
On this last step you can either add new columns to the flow or overwrite existing ones, just make sure that you are using the ones being checked.
I would suggest an alternate data model which allows you to keep your original data intact.
Add a multicast (this will allow the data to duplicate)
Have one flow handle the normal non-address flow
Add a new flow to handle person address data.
Add a script task (this will be used to normalize the addresses
Mark the key as input and all the address columns as input
Create a new output (call it Address) with PersonKey, AddressType, AddressLine1, AddressLine2, PostalCode, Country
Add this simple code.
AddressOutputBuffer.AddRow();
AddressOutputBuffer.PersonKey = Row.PersonKey;
AddressOutputBuffer.AddressType = "Address1";
AddressOutputBuffer.AddressLine1 = Row.Address1_Line1;
... (Add the rest in here)
AddressOutputBuffer.AddRow();
AddressOutputBuffer.PersonKey = Row.PersonKey;
AddressOutputBuffer.AddressType = "Address2";
AddressOutputBuffer.AddressLine1 = Row.Address2_Line1;
... (Add the rest in here)
Write this new Person Address info to a new table (you can build whatever logic you want to the queries you write or you can create a view to handle your specific logic.)
NOTE: You may need to null handle the code above
Ex:
AddressOutputBuffer.AddressLine1 = !Row.Address1_Line1_IsNull?Row.Address1_Line1:"";
I have id from the city that is supposed to be selected in dropdown list, but I can`t manage to preselect it. Should I select it from directive or is there any other way?
<select ng-model="cityId" ng-options="city.name for city in cities"></select>
Edit your ng-options to this:
city.id as city.name for city in cities
if you fetch the cities and don't know the ID's
you could say in your javascript success function (which returns the cities):
$scope.cityId = the_cities[0].ID
to set the first as selected
Else you could just say:
$scope.cityId = 1; //or anything that exists
You would need to use select as part for that, provided id is respective property on city object you would do:
ng-options="city.id as city.name for city in cities"
Otherwise you need to provide same object reference (of city object in the array) as the ng-model (if not using track-by).
When using track-by you would do:
ng-options="city.name for city in cities track by city.id"
and set the model as:
$scope.cityId = {id:'CITY1'};
When track by is used you do not need to worry about object references and it will actually have the value property of options reflecting exact id (unlike select as which keeps an internal map with index). This is helpful when doing form posts. But you should be careful not to mix it with select as since both are meant for different purposes and the implementation conflicts each other.
I'm trying to define a LOV with Universe Designer that when used in a #Prompt shows the user the item description, but gives back the corresponding item key as result of user selection.
e.g. From a dimension table of countries with two columns as COUNTRY_ISO and COUNTRY_NAME, I would like to show COUNTRY_NAME values to user with #prompt, but get back the corresponding COUNTRY_ISO as return value of #prompt.
This is possible using Index Awareness. I'll describe the solution using the sample "Island Resorts Marketing" universe, but the concept should map to your specific need.
For this example, we'll create a prompt on the "Country" object in the "Resort" class. The prompt will display the country names, but the condition will apply to the country_id field.
First, we need to identify the keys. On the Keys tab of the Resort\Country object, add a new Primary Key using Resort_Country.country_id as the source:
(in your case, you'll do this on the COUNTRY_NAME object, using COUNTRY_ISO as the primary key)
Next, we create the predefined condition that will include the prompt. Create a new Predefined Condition, named "Select country", with the following definition:
Resort_Country.country_id = #Prompt('Choose a country','A','Resort\Country',Mono,primary_key)
What we're doing is is applying the condition to the ID field (resort_country.country_id), but using the country name (the Country object) as the source. Note the "primary_key" parameter -- this tells BO to use the PK from the referenced object.
Now to test. Create a WebI report and select the "Select country" filter along with a field to display. I chose Service Line:
I run the report and am presented with a list of country names. I choose France, and I get a list of the Service Lines associated with France. The SQL generated by this query, reflecting my prompt selection, is:
SELECT
Service_Line.service_line
FROM
Service_Line,
Country Resort_Country,
Resort
WHERE
( Resort_Country.country_id=Resort.country_id )
AND ( Resort.resort_id=Service_Line.resort_id )
AND ( Resort_Country.country_id = 2 )
Note the very last line, which shows that the condition is applied using the ID, even though I selected the country name "France".
References:
- XI3.1 Designer Guide #Prompt info, starting on page 520
- Dave's blog on Index Awareness
- Dave's blog on Index Awareness with prompts
I am using Ruby on Rails v3.2.2, MySQL database and the AwesomeNestedSet gem in order to handle a nested set model data structure for places (addresses, cities, countries and so on). Columns present in the related places database table are name, parent_id, lft and rgt.
I would like to implement a method so to find records by their names and by related ancestor names. That is, for instance, when I search for "Spacca Napoli Street, Naples" (note: the comma , in the string is used as a constant separator) then I would like to return addresses with name Spacca Napoli Street having an ancestor (in my case, a city) with name Naples.
Is it possible (maybe, by using some RoR scope method)? If so, how to make that?
I'm making a student management system on apex. The short of it is a place where lecturers and students can log on. Lecturers create assignments, assign them, mark them, take attendance, record issues ...... all that, and students log on to view their attendance and results.
Now when a student clicks the "My Results" link it navigates to the same page that a lecturer sees, though the select list where a student is selected to view the results of is hidden. The select list displays the students name and returns the id for that student, which also happens to be the user name for a student to log in.
So i want to pass the value of the app-user when a student clicks the link so that only their results are shown.
I've tried to set
these items
:P10_SELECT_STUDENT
with these values
#APP_USER#
which works but no the message "no data found" is shown.
Just for testing i've set that select list to be displayed for a student, and when the page loads it loads with the null value at the top of the list which is
display value
select a student
return value
-1
I've gone and manually set the value passed to be the id of the test student. works a treat, the data loads for that student!!
So does anyone know why the #APP_USSER# value im sending isnt being set in the listbox
Thanks in advance
What you need is the session state of the APP_USER variable. In a query you would reference this with :APP_USER. When you need to pass on the value as a parameter for, for example, a link, you would use the substitution string notation &APP_USER. Much the same way you would refer any other variable/page item.
For example, setting up a button:
A good page to read up on Substitution strings: Application Builder Concepts
The hash-sign notation is commonly used for non-plsql-variables substitution, like the value of a column in report when passed through in a link,
Zac,
If the users haven't authenticate themselves then the :APP_USER parameter is null. If the user authenticated via a SSO, or via DB credentials or whatever you have in the application then the :APP_USER will get populated.
Here is what i understood :
In page 12 , P12_STUDENTS is a select list, and you want it to reflect the current student if he enters or the full list if he's a teacher right?
You don't need to pass :APP_USER via a link or a branch or whatever. It exists as a global Apex variable and is visible in page 12 via :APP_USER but again , its null if the user is not authenticated.
Your select list source should be like:
select display d, return r
from table
where (:APP_USER is NULL
OR (:APP_USER IS NOT NULL AND :APP_USER = student))
tell me if this helps?
regards,
Alex