NetSuite Phone Number Formatting - netsuite

I am trying to implement automatic phone number formatting into NetSuite I am having some issues getting my script to work. Basically if someone enters a phone number into a customer record, "1234567890" for example, it will automatically format to "(123) 456-7890". You can see my script below along with the error message I receive when creating a new script record.
Fail to evaluate script:
{"type":"error.SuiteScriptModuleLoaderError","name":"UNEXPECTED_ERROR","message":"missing ; before statement (SS_SCRIPT_FOR_METADATA#21)","stack":[]}

Why do you need a script for this? NetSuite already does this, based on the Phone Number Format setting at Setup > Company General Preferences. Check you have this field set correctly according to your preference.
If for whatever reason it turns out you do need a script for this, there are several issues with the script you posted:
There is a syntax error - mismatched parentheses/braces. Your code editor is trying to show you that with the red brace on line 8 and the red squiggly underline on the last parenthesis (line 23).
NetSuite record level client scripts must implement an entry point function. For formatting phone numbers this would be a fieldChanged() entry point. You would need to wrap the logic contained in lines 10 to 20 inside a function, and then reference that in the return statement at the bottom. EG: If you called the function phone() your return statement would be return {fieldChanged: phone}.
You are using SuiteScript 1.0 API functions (nlapiGetRecordId() and nlapiLoadRecord()) in a SuiteScript 2.0 script. Under some circumstances these functions may be available so it might work, but even if it does, it certainly isn't best practice.
Loading the record isn't necessary. When you implement an entry point function, the function is passed a context parameter. IE: function fieldChanged(context). That context parameter contains a reference to the current record (context.currentRecord). Work with that instead of attempting to load the record separately.

Related

Set Transaction Type to RETURN conditionally in maximo

In Work order tracking application in actuals tab materials section when user clicks on New row by default the transaction type = ISSUE . I would like to change this by default to RETURN and remove issue from the look up (I was able to remove ISSUE from the lookup). This requirement should only work for PM type work orders. Hence I tried to write an automation script on MATUSETRANS.ISSUETYPE attribute launch point however it throws null pointer expection which trying to perform setValue. I tried using 2L,7L and 11L however it doesn't work.
if(onadd) ==True:
mbo.setValue("ISSUETYPE",'RETURN')
Is there any other way to do this?
We basically need to trigger the code on a field that sets after ISSUETYPE is set using the out of the box code so I tried on field like currencycode or condrate (attribute launch point) and it works like charm. You will have to use 7L though to the existing code.

How to hide a field value in maximo with special characters similar to a bank account number

I have a requirement where i am importing some attribute data through integration into maximo.However the client demands the field value needs to hidden or encrypted with special characters and only the last few numbers to be shown similar to a bank account number. How do i achieve this?
An example suppose the field value is 1234567 client wants this to be shown as ****567
Here's a simple solution that should do it: define a persistent attribute (accountnum) to save your account number and a non persistent one to display its partially masked version (maskaccountnum).
Create an attribute launch point automation script to initialize the non persistent value.
Python Example:
if not mbo.isNull("accountnum") :
mbo.setValue("maskaccountnum", "****" + mbo.getString("accountnum")[-3:])
Add your non persistent attribute to your application.
I created a non persistent attribute as stated by JPTremblay.
and upon getting confirmation with client for a fixed range of numbers for the attribute ACCOUNTNUMBER there was no need for a dynamic script.
so i just created a object launch point script.
event is chosen as Initialize
and just one line of code
mbo.setValue("maskaccountnum", "************" + mbo.getString("accountnum")[-5:])
this did the trick. Language was chosen as Jython.

Saving textbox value from a test execution in Ranorex

I am automating Sharepoint list testing, filling up some field with values,
and like to save data I supplied to the field after.
Is there a way to automate saving the field value in a excel or csv?
In order to keep it simple, I would create two recordings and write to a text file (csv).
The first one would get the text values from the desired fields and return them in bound variables using Ranorex GetValue action.
The second recording would write the content of the bound variables to a text file, separating fields with ',' (or any other character that is suitable for the kind of data that is present in the fields) in a user code function.
If you have no idea how to write to a file in .NET, take a look at System.IO.File.AppendAllLines or similar functions.
You could also combine the 2 recordings in one, but then, re-useability would be limited the scope of the SharePoint page you are testing.
Do not forget that since Ranorex is using the .NET framework, you have access to all the functions provided by the framework in user code. With Ranorex, the usual question is not ask if something is possible. The real question is "how can it be done" and is the solution simple enough for testers to be able to use it!
Hope this helps!

msproject - creating an indicator that more than one resource is allocated to the task

I'm fairly new to MSProject and i believe my request is pretty simple:
I would like that an indicator show an icon when a task has more than one resource allocated to it.
is it possible?
p.s my goal is that people wont be able to add more than one resources per task. if there is a way to enforce it the indicator is not necessary
thanks
The basic formula is something like that: InStr([Resource Initials],","). Please pay attention that "," is a list separator in my locale. For other people that could be ";" and so on. There is a property of Application object: Application.ListSeparator but it isn't available in plain formula definition - you can create your VBA function which will just return the value and use your function.
Variation of the formula depends on what field are you going to use for it. If you plan to use one of Flag fields - just add > 0 at the end, for Number field you can just define a graphical indicator with greater than 0 condition.
Another option is to write your handler for event Application.ProjectBeforeAssignmentNew and check if there are any assignments defined for the task already

Problem getting value from "Checkbox group value prompt"

I've value prompt with ui:checkbox group
parameter: p_IsLastMonth
Name: Prompt_IsLastMonth
ItemCount: 1; UseValue:Yes, DisplayValue: LastMonth?
and two Date Prompts.
Whenever the checkbox is checked, the UseValue 'Yes' is passed to the parameter 'p_IsLastMonth'. But whenever the checkbox is left as it is, it results in an error.
Element 'selectOptions' is not valid for content model: 'All(style,defaultSelections,conditionalStyles,conditionalRender,XMLAttributes)'
I also tried giving a default value. But the default value has to be in the collection. But i want only one checkbox to be displayed.
I tried with html checkbox. But i'm not able to send the value 'either yes or no' to the parameter through javascript because however the finish button overrides the value.
Any help?
There are 2 ways you can use Parameters:
Evaluate Parameter value
Evaluate expression against Parameter value.
Either way your Parameter has some value, and no value is a kind of value. And you need to cater for empty value in some way. Eg:
If (?Parameter? <>'') then ([Selection Criteria] = 'True') Else (1=1)
OR
([Selection Criteria] = ?Parameter?) OR ?Parameter? = ''
There other ways of using parameters too. You should choose one that better suits situation and coding practices you are following.
You can use optional checkbox or text item. In Cognos 10 I get "Deselect" option under checkbox group.
Unfortunately, I don't think you can accomplish what you want to do with only one checkbox. The only way you can leave a value prompt unselected and still submit the prompt page is to make it "optional", which means no value will be passed. An option is to use two check boxes and make them "required" so that either "yes" or "no" must be selected (but this can result in both being selected, which isn't good), or preferably use a radio list with two values and "yes" as the default. There may be a javascript answer to this, but I try to avoid that as much as possible since it sometimes leaves you open to version upgrade issues. Using a radio list is your easiest option.
Well here is something that will work. I've done advanced scorecarding and dashboarding for years with Cognos and Javascript will work:
Create a real cognos parameter that has both choices you need Yes/No with no being the default. Put them perhaps in a html table somewhere off the main real-estate of the report/param canvas. Once you have the param configed you can make the size as small as you want and then make the table/checkbox invisible by turning the visible property to no. Basically the users won't see these params. Don't do box-type = non or the parameter won't even get generated. You could also wait on hidding them until we get step 3 working(Make it easier to troubleshoot).
Then create a HTML parameter that the user will use to interact with in the style that you want the users to see, and use javascript onchange events to manipulate the real hidden parameter by finding it via DOM model. You can make finding it easier by perhaps surrounding the hidden params with an HTML tag that has a unique name/ID and referencing the child items from there.
Since your cognos parameter is invisible you may not even need to use a check box... you could simply use a hidden text box that has stores Yes/No. This will make your coding simplified on the javascript until you get used to it.
Also When programming with javascript on Cognos i find using alert to echo a object's innerhtml to screen while troubleshooting to be very handy.
* One other less impressive approach if i remember right as well..
1. Leave your original cognos style checkbox alone and create another cognos prompt that is always defaulted to "-NO-" and hidden on the canvas.
2. In the expressions used to evaluate the parameters the would evaulate the concatenation values of both params and you could take logical action based on those values. So if the concatted results were "-No-" then you know the original paramater was not selected and to use "No". etc... I believe there could be a nuance to getting this to evaluate correctly in the expression editors but i have got this owrking before as well. * So i your case if the concatted results first 3 characters = "Yes" the "Yes" otherwise no.

Resources