How to pass data from one form to another suitescript - netsuite

Well it looks like I need to suite script this.
I want to populate a field in my child record from the form that is creating the record.
When the user clicks to add a new child record, I want to pass some info to the creation of that child record from the current parent that initialized the create child.
How is this done?
MORE INFO:
I originally looked at Sourcing and filtering, but that was dependent on the parent record being the same. Let's say I have a note record. Meanwhile I have other entities which can have a note created and linked to it.
Something like adding the set name to a note:
Set
-->> Books --> Note (set name = books.set.name )
-->> Authors --> Note (set name= authors.set.name)
So unless I can use some eval technique, I would think I should start my dive into suite script.

The workaround I found was to use window.opener in a client script:
function rulePageInit(){
var wo = window.opener.nlapiGetFieldValue ('custrecord_configurator');

You can script this, but you do not necessarily have to. NetSuite's primary mechanism for doing this is Sourcing.
On the definition of each custom field that you want to populate from the parent, you just need to set up the Sourcing and Filtering tab appropriately to pull data from the parent record. I believe you will set the Source List to be the field that links to the parent, and then you will set the Source From to be the field on the parent that you are copying data from.
If you only want the field to be sourced once at the time of creation, then you can check the Store Value checkbox on the field definition. This will set the field once and then divorce it from the parent record so that you can change the two fields independently.
If you want the field to dynamically pull from the parent every time you view the record, then you should uncheck Store Value. Be aware that unchecking this means the field will no longer be scriptable or searchable.
See the NetSuite Help page titled Setting Sourcing Criteria for more details about the relevant settings.

Related

Lotus notes, edit one form from another

Basically what I want to do is create a form whilst within another form and pass values from the earlier form to the second. Complicated I know but here is what I got.
#Do(#Command([Compose];"LPK"); #SetField("PR_Make"; PR_Make))
The fields in both forms have the same name and this code is called when first document is attempted to be saved.
I think instead of editing the field on the second form it just saves a field as itself instead. Any help appreciated.
The best and common way is to enable form property "Formulas inherit values from selected document" in second form "LPK".
Add a default value formula to second form's fields you want to inherit and put just the name of field itself in. For your example default value formula it would be
PR_Make
Make sure you save document first and then create the new document.
Knut Hermann's answwer is the 'standard' way of achieving such things but there are other methods- eg you can use environment variables ..
Something like:
#Environment("PR_Make") := PR_Make;
#Command([Compose];"LPK");
Then set the default value for PR_Make in your new form as ..
#Environment("PR_Make")
FYI Environment variables are written to the user's Notes.ini file and so remain even after Notes has been closed and re-opened. #Environemt doens't work too well with Web applications as it uses the server's notes.ini.
An alternative would be to use profile documents:
#SetProfileField( "PRDefaults"; "PR_Make" ; PR_Make;#Username);
#Command([Compose];"LPK");
.. in the default field for PR_Make on new form :
#GetProfileField( "PRDefaults"; "PR_Make"; #Username);
Profile documents are stored as a kind of hidden document in the Notes database and persist with the database. The last parameter sets a further subdivision by username so each user gets their own profile doc - a bit like a personal profile for "PRDefaults". You can miss this last parameter #Username out, to have one profile doc per database but there's a risk of two people trying to use it at the same time and clashing.
Profile docs also work with web applications.

Mapped field not updating when parent record does

2013 On-Premise
Hello,
I have a parent record and a subgrid that can create a related record. When I create this related record several of the parent fields are mapped over to save the user double entry & mistakes.BTW the related record is being created via a quick create form.
Everything works great....at first.
If the parent record changes and the changes are saved. Then a new related record created the mapped fields DO NOT reflect the updated parent?
Further this behavior exist if there are NO related records or several.
Is my relationship not properly defined...i.e. needing cascading?...I thought that was just for cascading deletes???
Any input greatly appreciated
#Dave
My apologies...perhaps I have not been clear or I am not understanding you.
....If you need the previously mapped fields to change when the parent record values change....
This is where I am wondering if I am not being clear or understanding. This is happening on the "create" not existing records.
So I thought perhaps incorrectly if I changed the parent record and then went to create a new related record it would get the new mapping?? BOLD just so text isn't lost between picts.
The mapping functionality is only applied when the child record is created. Cascading only applies to events like deleting, sharing, unsharing, assigning, and re-parenting the parent record. Mapping is not involved in cascading at all. - http://msdn.microsoft.com/en-us/library/gg309412.aspx
If you need the previously mapped fields to change when the parent record values change, this would best be addressed with a plugin. You may also consider making the child's mapped fields read only so user's don't think they can enter information in the child record's fields that get populated from the parent.

update netsuite parent field via suitescript in view mode

I have scripts that react off of, for example, a client Recalc client event. For example, on my form I have a subtab that users may add or remove items from. Based on actions on this subtab (housing a child record of the parent) I would like a field on the parent to update (say to show a total from the children records).
As I was saying, these events seem to work fine if in edit mode but they do not work correctly in view mode. (even in view mode these child records have a "Delete" option at the end of each row in the subtab. This was provided by netsuite by default.
I wondered if anyone had any tips to best allow this parent field to update real time while in updating the subtab rows with the form in view mode.
Thanks.
You can make a custom field on the parent (header) whose value is determined by saved search. For instance, make a saved search that totals the line values by transaction. Be sure to make it filter by transaction in the Available Filters tab. Make the search public so everyone can use it.
Create the custom field that sources the total from the saved search. Make sure to uncheck the "Store Value" checkbox, as you don't want to store the data, you want to reference the search results. You do this on the Validation and Defaulting tab. You'll see a field for Saved Search there. Choose the search you created above.
As you remove/add/change lines on the transaction, the field updates accordingly. In essence, you don't need a single line of code to make this work - it's all in how you create the search and the custom field that references it.
I have a similar situation posted here.
The NetSuite team answered me by email, and it happens you can't really achieve this on the view mode: some API methods are not available. Their suggestion to my case (and I think it applies to yours too) was really to force a refresh on the whole page.
Of course, you can always achieve this accessing the DOM elements directly, but this isn't a best practice, as your code can stop working if these elements change on a version update.
I had the same problem, I'm not able to restrict on view or remove edit button. But, there was one alternative solution with workflows, you can deploy workflow on child record edit mode restrictions, then if the user clicks edit on view then the record will not be available to edit. This concern will apply to custom record as well.

SharePoint Custom Field - is it possible to handle item deletion event?

I'm expanding SPFieldText and BaseFieldControl to create a custom field. The field saves some data externally (for example, on a database or on another list)
Within the control I'm able to handle Edit and New events (using ControlMode).
I'd like to run a function and clean up some data when an item containing my field is deleted. Is this possible, in the context of a custom field?
No, the field has no "knowledge" of the item it is contained in. You could however perform the cleanup by creating an ItemEventReceiver.

SPWorkflowTaskProperties.ExtendedProperties aren’t populating the fields in my task

I am attempting to pass information from a task created within a workflow to its corresponding task form. Prior to the CreateTask activity, I create an SPWorkflowTaskProperties and fill it with the usual info (title, assigned-to, etc). I also add some elements to the ExtendedProperties property. However, those custom properties never make it into the Task.
I've tried setting the property key to:
the Guid of one of my task' content
type's fields;
the internal name of
one of my task' content type's
fields;
an unrelated name (in the
hopes of getting the info into the
task's properties instead of its
fields).
Nothing works. The task, once created, contains only the built-in field values I have set. None of values I explicitly added to the extended properties show up.
The (simplified) sequence of my activities is as follows:
PrepareTask. This is a custom
activity that contains the
SPWorkflowTaskProperties
CreateTask. The task properties are bound to the one in the PrepareTask activity.
OnTaskCreated. The task properties are bound to the one in the PrepareTask activity.
While (task not complete)
OnTaskChanged
I am using WSS 3.0 SP1 and an ASPX (NOT InfoPath) task form.
I still don't know why my original solution didn't work. But I have found a workaround. My sequence of activities is now:
CreateTask
OnTaskCreated
CopyTaskItems. This is a custom
activity that puts values into my
custom task's fields, then updates
the task.
While (task not complete)
OnTaskChanged
So I have to create the task, then immediately poke values into it and update.
I hope this will help some future reader of this question.
You should be using a ItemMetadata.xml document as a secondary datasource that contains the definition of the fields that you want to pass to your task form. Something like:
<z:row xmlns:z="#RowsetSchema"
ows_Instructions=""
ows_Body=""
ows_Comments=""
ows_ApprovalStatus=""
/>
The File name is important btw.
Notice the ows_ (as it used the webservices all fields in the list will be prefixed with ows.)
Then in you infopath form, set the default value of each control you want to display this information in. Hit the fx button and insert a field or group from the secondary datasource.
A good resource: http://weblog.vb-tech.com/nick/archive/2007/02/25/2207.aspx

Resources